How to identify the "parent" of a Centermark?

Programming and macros
User avatar
loeb
Posts: 68
Joined: Sun Jan 16, 2022 5:55 pm
Answers: 1
x 39
x 10

How to identify the "parent" of a Centermark?

Unread post 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
by josh » Sat May 07, 2022 9:34 pm
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
Go to full post
User avatar
josh
Posts: 295
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 508

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

Unread post 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
Post Reply