Page 1 of 1

How to identify the "parent" of a Centermark?

Posted: Sat May 07, 2022 8:21 pm
by loeb
Is there a way, using VBA, to identify the geometry (arc, circle, hole, etc) that a CenterMark is attached to? If that's possible, I'd then want to be able to get properties of that geometry, such as diameter/radius.

Thank you

Re: How to identify the "parent" of a Centermark?

Posted: Sat May 07, 2022 9:34 pm
by josh
Meh, I'll post it here too for posterity.

Sub main()
Dim swApp As SldWorks.SldWorks
Dim swDwg As SldWorks.DrawingDoc
Dim swAnnot As SldWorks.Annotation
Dim swView As SldWorks.View
Dim swEnt As SldWorks.Entity

Set swApp = Application.SldWorks
Set swDwg = swApp.ActiveDoc
Set swView = swDwg.GetFirstView
Set swView = swView.GetNextView
Set swAnnot = swView.GetFirstAnnotation3
While Not swAnnot Is Nothing
If swAnnot.GetType = swCenterMarkSym Then
Set swEnt = swAnnot.GetAttachedEntities3(0)
swEnt.Select4 True, Nothing
End If
Set swAnnot = swAnnot.GetNext3
Wend

End Sub