Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgeAssembly.AssemblyDocument
Dim objParts As SolidEdgeAssembly.Occurrences
Const TESTFILE = "T:\vbtests\testcases\Sample.asm"
Dim lngCount As Long
' Report errors
Const PI = 3.14159265358979
' 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
Call objDoc.Close
' opening an existing assembly file
Set objDoc = objApp.Documents.Open(TESTFILE)
' getting the collection of parts in the assembly document
Set objParts = objDoc.Occurrences
' getting the number of parts in the collection
lngCount = objParts.Count
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objParts = Nothing
End Sub