-
Re: Count the number of lines, circles, and arcs in a part?
Kelvin Lamport Dec 9, 2012 8:35 AM (in response to Dimas Ewangga)Try the Mad Mango's Sketch Census Tool macro from http://www.esoxrepublic.com/freeware/index.html
-
Re: Count the number of lines, circles, and arcs in a part?
Dimas Ewangga Dec 14, 2012 11:53 PM (in response to Kelvin Lamport)Thanks kelvin, the sketch census is working, but i still can't get the code to get the number of lines, circles, and arcs in a sketch.
i tried to decompile the mad mango macro's .dll file with ".net reflector" but it didn't work (error: 'C:\Program Files\Esox Republic Tools\Sketch Census\SketchCurveCount.dll' is not a .NET module.)
because what i'm trying to do is to get the sketch attributes into some variables then make the equation for my main program.
is there any way to get the sketch attributes or to view this mad mango's code?
thanks in advance.
-
-
Re: Count the number of lines, circles, and arcs in a part?
Artem Taturevych Dec 15, 2012 7:43 PM (in response to Dimas Ewangga)Try this:
ModelDoc2::FirstFeature->Feature::GetNextFeature->Feature::GetSpecificFeature2->
Sketch::GetArcCount.
Sketch::GetEllipseCount.
Sketch::GetLineCount2.
Sketch::GetParabolaCount.
Sketch::GetPolyLineCount.
Sketch::GetSketchPointsCount2
Sketch::GetSketchSlotCount.
Sketch::GetSplineCount.
______________________
Regards,
Artem Taturevych
Application Engineer at Intercad
Tel: +61 2 9454 4444
-
Re: Count the number of lines, circles, and arcs in a part?
Dimas Ewangga Dec 16, 2012 2:41 AM (in response to Artem Taturevych)thanks, i haven't tried it yet, and i'll let you know if it works as soon as possible.
-
Re: Count the number of lines, circles, and arcs in a part?
Dimas Ewangga Dec 17, 2012 1:00 PM (in response to Artem Taturevych)okay, so here's my macro:
Function GetSketchCount() As Integer
Dim swApp As SldWorks
Dim swModel As ModelDoc2
Dim swSelMgr As SelectionMgr
Dim swFeat As Feature
Dim sketch As ISketch
Dim CrossHatchOption As Short
Dim pointcount As Integer
Dim linec As Integer
Dim arcc As Integer
Dim ellc As Integer
Dim parac As Integer
Dim polyc As Integer
Dim splc As Integer
linec = 0
arcc = 0
ellc = 0
parac = 0
polyc = 0
splc = 0
On Error GoTo ehandling
swModel = swApp.ActiveDoc
swSelMgr = swModel.SelectionManager
swFeat = swSelMgr.GetSelectedObject4(1)
swSketch = swFeat.GetSpecificFeature
linec = Sketch.GetLineCount2(1)
arcc = Sketch.GetArcCount
ellc = Sketch.GetEllipseCount
parac = Sketch.GetParabolaCount
polyc = Sketch.GetPolyLineCount(1)
splc = Sketch.GetSplineCount(1)
MsgBox("Total of line: " & linec & " Total of arc: " & arcc & " Total of ellipse: " & ellc & " Total of parabola: " & parac, vbInformation, "Sketch Statistic")
GoTo THEEND
ehandling:
MsgBox("Please select a sketch", vbCritical, "Error")
THEEND:
End Function
after i select a sketch and click the button, it shows the error messagebox instead the skecth statistic. I don't know what's wrong with my macro. can somebody help me?
-
Re: Count the number of lines, circles, and arcs in a part?
Artem Taturevych Dec 17, 2012 4:23 PM (in response to Dimas Ewangga)Your variable for sketch is swSketch but not sketch. Should be
Dim swSketch as ISketch
...
linec = swSketch.GetLineCount2(1)
arcc = swSketch.GetArcCount
ellc = swSketch.GetEllipseCount
parac = swSketch.GetParabolaCount
polyc = swSketch.GetPolyLineCount(1)
splc = swSketch.GetSplineCount(1)
______________________
Regards,
Artem Taturevych
Application Engineer at Intercad
Tel: +61 2 9454 4444
-
Re: Count the number of lines, circles, and arcs in a part?
Dan Miel Dec 17, 2012 4:40 PM (in response to Artem Taturevych)If you get the number of entities in a sketch like this and then create a pattern from the resulting feature I don't think the count would be accurate.
When I have done similar projects with sheet metal I would get the body, then the faces and loop through the faces to find the largest one and then get the edges of that face and examine each edge to see what it is. It can be a fairly involved program.
Dan Miel
SW 2011
-
-
-
-
Re: Count the number of lines, circles, and arcs in a part?
Dimas Ewangga Dec 21, 2012 6:35 AM (in response to Dimas Ewangga)okay thanks all. it works, and just needs some little adjustments.
-
Re: Count the number of lines, circles, and arcs in a part?
Jackie Yip Dec 27, 2016 9:29 AM (in response to Dimas Ewangga)Hello,
Was wondering if anyone still had a macro for this, this would be very useful as I am assisting someone with generating a toolpath for mastercam, it would be nice to figure out how many entities the sketch contains for this purpose.
Thank you,
Jackie
-
Re: Count the number of lines, circles, and arcs in a part?
Dave Bear Dec 27, 2016 9:33 AM (in response to Jackie Yip)
-