Hello,
In a drawing context, I would like to select a temporary axis of a weldment cutlist body and draw some entities over using some custom properties as parameters.
So, to retrieve the body from the selected temporary axis, I use:
Sub main()
Dim app As SldWorks.SldWorks
Dim doc As SldWorks.ModelDoc2
Dim selmgr As SldWorks.SelectionMgr
Dim selcount As Integer
Dim i As Integer
Dim seltype As Long
Dim feat As SldWorks.Feature
Dim axis As SldWorks.RefAxis
Dim face As SldWorks.Face2
Dim body As SldWorks.Body2
Set app = Application.SldWorks
If app Is Nothing Then Exit Sub
Set doc = app.ActiveDoc
If doc Is Nothing Then Exit Sub
Set selmgr = doc.SelectionManager
If selmgr Is Nothing Then Exit Sub
selcount = selmgr.GetSelectedObjectCount2(-1)
If selcount = 0 Then Exit Sub
For i = 1 To selcount
seltype = selmgr.GetSelectedObjectType3(i, -1)
If seltype <> SwConst.swSelectType_e.swSelDATUMAXES Then GoTo Next_i
Set feat = selmgr.GetSelectedObject6(i, -1)
If feat Is Nothing Then GoTo Next_i
Set axis = feat.GetSpecificFeature2
If axis Is Nothing Then GoTo Next_i
If axis.IsTempAxis = False Then GoTo Next_i
Set face = axis.GetTempAxisReferenceFace
If face Is Nothing Then GoTo Next_i
Set body = face.GetBody
If body Is Nothing Then GoTo Next_i
Debug.Print body.name
Next_i:
Next i
End Sub
After this, I know how to find CutList folder containing this body.
But between, I need to know from which part/config this body come from.
Some advice will be welcome.
ISelectionMgr::GetSelectedObjectsComponent4 is what I am looking for: