Insert Mate Load Reference Example (VBA)
This example shows how to insert a mate load reference.
'-------------------------------
'
' Preconditions:
'
' (1)
Assembly document is open.
' (2)
Mate to add load reference is selected.
' (3)
Supplemental faces for load reference are selected.
'
' Postconditions: Mate load reference is inserted to the
selected mate.
'
'--------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swAssemblyDoc As SldWorks.AssemblyDoc
Dim swMate As SldWorks.Mate2
Dim swMateLoadRef As SldWorks.MateLoadReference
Dim swFeat As SldWorks.Feature
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swAssemblyDoc = swModel
'
Get the selected mate
Set swFeat = swSelMgr.GetSelectedObject6(1,
0)
Set swMate = swFeat.GetSpecificFeature2
' Insert the load reference based on the selected mate
and supplemental faces
Set swMateLoadRef = swAssemblyDoc.InsertLoadReference(swMate)
Debug.Print "This load reference added to the "
& swFeat.name; " mate
= "; swMateLoadRef.name
Debug.Print "Number of supplemental faces for Component1
= ";
swMateLoadRef.GetFacesCount(0)
Debug.Print "Number of supplemental faces for Component2
= ";
swMateLoadRef.GetFacesCount(1)
End Sub