Why Why Why .......

Is There a way to get all sketches in part doc in an array or just to cycle throught them . and does any body know why modeldoc2::getactivesketch is always NOTHING

regards Vasil Tabakov

Reply to
V.Tabakov
Loading thread data ...

Try this sample from SolidWorks API Support Examples that autodimensions all sketches in a model:

formatting link

Can you give an example?

Reply to
Paul Delhanty

The code segment i had tried was :

Sub main() Set swmodel = swApp.ActiveDoc Set swselmgr = swmodel.SelectionManager Set swpart = swmodel Set swsketch = swmodel.GetActiveSketch2 'this is always NOTHING 'addto " sketch count " & swmodel.ge If swsketch Is Nothing Then MsgBox " there isn't active sketch !! " Else MsgBox " Sketch is now present !! " End If loopsch swsketch 'function to loop throught sketchsegments 'loopbodies swpart fmain.Show End Sub

Reply to
V.Tabakov

message news:...

I just ran your code in SW2004 SP0. For me if, I am editing a sketch when I invoke the macro, then I do get the message "Sketch is now present". For GetActiveSketch2 not to return NOTHING it is not sufficient for the sketch to be merely selected; it has to be being edited at the time. The API documentation sometimes refers to this as activated.

What are you trying to achieve? Your previous post mentions looping through all the sketches in a part. Did you find the autodimension all sketches sample on the SolidWorks website?

Reply to
Paul Delhanty

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.