Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgeAssembly.AssemblyDocument
Dim objFirstPart As SolidEdgeAssembly.Occurrence
Dim objTemp1 As Object
Dim objRef1 As Object
Dim objSecondPart As SolidEdgeAssembly.Occurrence
Dim objTemp2 As Object
Dim objRef2 As Object
Dim objAxial As SolidEdgeAssembly.AxialRelation3d
Const TESTFILE = "T:\vbtests\TestCases\mtgpin.par"
' Used for temporary storage of datadump return string
Dim sDumpStatus As String
' 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
' Place a Part on the AssemblyDocument
Set objFirstPart = objDoc.Occurrences.AddByFilename(TESTFILE)
' Get a SideFace on the above Part
Set objTemp1 = objFirstPart.PartDocument.Models(1).RevolvedProtrusions(1).SideFaces(4)
' Create a reference to a side face on the part for using while adding an Axial relation
Set objRef1 = objDoc.CreateReference(Occurrence:=objFirstPart, entity:=objTemp1)
' Place another Part on the AssemblyDocument
Set objSecondPart = objDoc.Occurrences.AddByFilename(TESTFILE)
' Get a SideFace on the above Part
Set objTemp2 = objSecondPart.PartDocument.Models(1).RevolvedProtrusions(1).SideFaces(4)
' Create a reference to a side face on the part for using while adding an Axial relation
Set objRef2 = objDoc.CreateReference(Occurrence:=objSecondPart, entity:=objTemp2)
' Remove the Ground Relation on the Second Part
Call objSecondPart.Relations3d(1).Delete
' Add an Axial Relation between the two Parts
Set objAxial = objDoc.Relations3d.AddAxial(Axis1:=objRef1, Axis2:=objRef2, NormalsAligned:=True)
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objFirstPart = Nothing
Set objTemp1 = Nothing
Set objRef1 = Nothing
Set objSecondPart = Nothing
Set objTemp2 = Nothing
Set objRef2 = Nothing
Set objAxial = Nothing
End Sub