Why Why Why .......

Discussion in 'SolidWorks' started by V.Tabakov, Dec 5, 2003.

  1. V.Tabakov

    V.Tabakov Guest

    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
     
    V.Tabakov, Dec 5, 2003
    #1
  2. Try this sample from SolidWorks API Support Examples that autodimensions all
    sketches in a model:

    http://files.solidworks.com/API/Examples/00000/0200s/0229/Example.htm

    Can you give an example?
     
    Paul Delhanty, Dec 5, 2003
    #2
  3. V.Tabakov

    V.Tabakov Guest

    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
     
    V.Tabakov, Dec 6, 2003
    #3
  4. 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[/QUOTE]

    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?
     
    Paul Delhanty, Dec 6, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.