This website uses cookies to ensure you get the best experience on our website. By using our website you agree on the following Cookie Policy, Privacy Policy, and Terms Of Use
This VBA macro selects equal size sketch arcs to the pre-selected input sketch arc. Only arcs in the sketch of the original input arc are selected. Macro works both for active and inactive sketch.
Options
Macro can be configured by changing the values of the constant at the beginning of the macro
Const EPS AsDouble = 0.0000000001
Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
OnErrorGoTocatchtry:
Dim swModel As SldWorks.ModelDoc2
Set swModel = swApp.ActiveDoc
IfNot swModel IsNothingThenDim swSkSrcArc As SldWorks.SketchArc
Set swSkSrcArc = swModel.SelectionManager.GetSelectedObject6(1, -1)
IfNot swSkSrcArc IsNothingThenDim radius AsDouble
radius = swSkSrcArc.GetRadius()
Dim swSketch As SldWorks.Sketch
Set swSketch = swSkSrcArc.GetSketch
Dim vSegs AsVariant
vSegs = swSketch.GetSketchSegments()
Dim i AsIntegerFor i = 0 To UBound(vSegs)
Dim swSkSeg As SldWorks.SketchSegment
Set swSkSeg = vSegs(i)
If swSkSeg.GetType() = swSketchSegments_e.swSketchARC ThenIfNot swSkSrcArc Is swSkSeg ThenDim swSkArc As SldWorks.SketchArc
Set swSkArc = swSkSeg
If Abs(swSkArc.GetRadius() - radius) < EPS Then
swSkSeg.Select4 True, NothingEndIfEndIfEndIfNextElse
Err.Raise vbError, "", "Please select sketch arc"EndIfElse
Err.Raise vbError, "", "Open model"EndIfGoTofinallycatch:
swApp.SendMsgToUser2 Err.Description, swMessageBoxIcon_e.swMbStop, swMessageBoxBtn_e.swMbOk
finally:
EndSub
Notifications
Join session by SOLIDWORKS and PDM API expret Artem Taturevych at 3DEXPERIENCE World 2025 on Feb 26 at 08:30 AM CST to explore 10 essential macros for automating drawings, assemblies, custom properties, and more