Private Sub Form_Load()
Dim objApp As SolidEdgeFrameWork.Application
Dim objDoc As SolidEdgeAssembly.AssemblyDocument
Dim objOccurrence As SolidEdgeAssembly.Occurrence
' Local variables to be declared here
Const TESTFILE = "T:\vbtests\testcases\Sample.asm"
Dim bActivate As Boolean
' Create/get the application with specific settings
On Error Resume Next
Set objApp = GetObject(, "SolidEdge.Application")
If Err Then
Err.Clear
Set objApp = CreateObject("SolidEdge.Application")
Set objDoc = objApp.Documents.Add("SolidEdge.AssemblyDocument")
objApp.Visible = True
Else
Set objDoc = objApp.ActiveDocument
End If
On Error GoTo 0
'Open an existing assembly Document
Set objDoc = objApp.Documents.Open(TESTFILE)
'Get an Occurrence in the assembly
Set objOccurrence = objDoc.Occurrences.Item(3)
'Get the Display state of this Occurrence i.e, Activated or LitePart
bActivate = objOccurrence.Activate
'Change the display state
objOccurrence.Activate = Not bActivate
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objOccurrence = Nothing
End Sub