ronin2307
Industrial
- Mar 28, 2005
- 29
Hi I am extremely new to sw programming and I am having some troubles. Here is my code in VB.Net
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim swApp As SldWorks.SldWorks
Dim swBomTable As SldWorks.BomTableAnnotation
Dim fileerror As Long
Dim filewarning As Long
Dim swView As SldWorks.View
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swError As Long
swApp = CreateObject("SldWorks.Application")
Try
swModel = swApp.ActivateDoc2("C:\IF 53914.slddrw", True, swError)
swSelMgr = swModel.SelectionManager
swView = swSelMgr.GetSelectedObject5(1)
swBomTable = swView.GetBomTable
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
I always get the OBJECT REFERENCE IS NOT SET TO AN INSTANCE OF AN OBJECT, because swView is NOTHING. Selection manager report 0 selected objects in the debug view.
any help will be highly appreciated
Thanx
Iggy
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim swApp As SldWorks.SldWorks
Dim swBomTable As SldWorks.BomTableAnnotation
Dim fileerror As Long
Dim filewarning As Long
Dim swView As SldWorks.View
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swError As Long
swApp = CreateObject("SldWorks.Application")
Try
swModel = swApp.ActivateDoc2("C:\IF 53914.slddrw", True, swError)
swSelMgr = swModel.SelectionManager
swView = swSelMgr.GetSelectedObject5(1)
swBomTable = swView.GetBomTable
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
I always get the OBJECT REFERENCE IS NOT SET TO AN INSTANCE OF AN OBJECT, because swView is NOTHING. Selection manager report 0 selected objects in the debug view.
any help will be highly appreciated
Thanx
Iggy