Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgeAssembly.AssemblyDocument
Dim objPart As SolidEdgeAssembly.Occurrence
Dim objRelations3d As SolidEdgeAssembly.Relations3d
Dim i As Integer
Const TESTFILE = "T:\vbtests\testcases\Sample.asm"
' 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 document
Set objDoc = objApp.Documents.Open(TESTFILE)
' getting a aprticular part in the assembly document
Set objPart = objDoc.Occurrences.Item(2)
' getting the relations3D object of the assembly document
Set objRelations3d = objDoc.Relations3d
' deleting the existing relations in the assembly
For i = objRelations3d.Count To 1 Step -1
objRelations3d(i).Delete
Next
' placing a ground relation on the part
Call objRelations3d.AddGround(Occurrence:=objPart)
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objDoc = Nothing
Set objPart = Nothing
Set objRelations3d = Nothing
End Sub