Hello
A rookie question, is there a way to list the contents of a sketch? I would like to know how many arcs, lines ... 30 years ago on my favorite Cadkey at the time, it was done in one click. Now I'm going around in circles a bit.
I am attaching a small Solidworkian video for the occasion
Have a good day and good luck
Thank you all
etiaffage.mp4
1 Like
Hello
Create a new macro and insert this code:
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swSketch As SldWorks.Sketch
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSketch = swModel.GetActiveSketch2
If swSketch Is Nothing Then
Set swSelMgr = swModel.SelectionManager
If swSelMgr.GetSelectedObjectCount2(-1) = 0 Then Exit Sub
If swSelMgr.GetSelectedObjectType3(1, -1) <> swSelectType_e.swSelSKETCHES Then Exit Sub
Dim swFeat As SldWorks.Feature
Set swFeat = swSelMgr.GetSelectedObject5(1)
Set swSketch = swFeat.GetSpecificFeature
End If
If swSketch Is Nothing Then Exit Sub
Dim myText As String
myText = " Nombre de lignes = " & swSketch.GetLineCount
myText = myText & vbCrLf & " Nombre d'arcs = " & swSketch.GetArcCount
myText = myText & vbCrLf & " Nombre de points = " & swSketch.GetSketchPointsCount
myText = myText & vbCrLf & " Nombre d'éllipses = " & swSketch.GetEllipseCount
myText = myText & vbCrLf & " Nombre de paraboles = " & swSketch.GetParabolaCount
MsgBox myText
End Sub
Starts the macro with an open or selected sketch
1 Like
Oh oh that's going to disendanger me in API and other macro. Besides, it seems very clear to me, and it works
Thank you very much
1 Like