API, retrieving names of sketch entities.

Discussion in 'SolidWorks' started by Tony Van De Velde, Dec 13, 2004.

  1. Hi,

    Can anyone tell me how to obtain the names (e.g. Point1, Line3, Spline2,
    etc...) of the sketchsegments in an active sketch.
    SolidWorks shows this information when right-clicking on a sketchsegment.
    However, I don't seem to find any API-function which gives me that info.
    I need these names for use with SelectByID2.
    Any help is greatly appreciated!

    Thanks,
    Tony
     
    Tony Van De Velde, Dec 13, 2004
    #1
  2. I would think you could use the Sketch.GetSketch segments call to get a
    handle to sketch segments in the sketch. Then, you can just iterate through
    those to get the names.

    Evan
     
    Evan T. Basalik, Dec 13, 2004
    #2
  3. Yes, I also thought it was that simple. But sadly enough the interface
    SketchSegment doesn't seem to have a function GetName or something like
    that. Or I'm not seeing it?
    It has GetID but that gives me two integers and that's not what I'm
    searching for.

    Thanks,
    Tony


    "Evan T. Basalik" <Evan(do not dare spam me -
    remove)> schreef in bericht
     
    Tony Van De Velde, Dec 13, 2004
    #3
  4. Tony Van De Velde

    CS Guest

    Are you selecting segments that you created durring the running macro or
    created before hand. How are you going to know wether you want Line1, Line2
    or Line15. I ask because there may be another way to select the appropriate
    line without the SelectByID.

    Corey
     
    CS, Dec 13, 2004
    #4
  5. I am selecting existing segments created outside a macro. Let me explain the
    situation. We're programming an addin using C#.
    This addin helps us to create aluminium constructions (conservatories). One
    point of our design is the creation of the roof panels.
    The sketch which defines the roof panel must be dimensioned. Therefore I
    need to select sketchpoints and sketchsegments (lines).
    I was going to use the API-functions SketchPoint.Select4 and
    SketchSegment.Select4, but these are flawed when using in-context.
    I have reported this to SW and they've issued SPR's. However, I am trying to
    work around the problem.
    That's why I'm trying to use SelectByID. This function works correctly, but
    only when I can give the sketch entity name as a parameter.
    Unfortunately, there doesn't seem to be a way to retrieve that name.
    I hope this clarifies the situation a bit.

    Regards,
    Tony
     
    Tony Van De Velde, Dec 13, 2004
    #5
  6. Tony Van De Velde

    CS Guest

    A stab in the dark but if you use Sketch.GetLines2 and assume that the first
    segment in the safe array would be Line1 and the second Line2, or more
    likely ID has something to do with the number. If I had time I would test
    some code for you but I just don't today.

    Corey
     
    CS, Dec 13, 2004
    #6
  7. Tony Van De Velde

    dudi Guest

    Hi
    Try SketchSegment::GetID this gives you a uniq couple of numbers
    ,associated with the type of segment, which corresponds to the number
    you see in the selection.

    regards

    dudi peer
     
    dudi, Dec 13, 2004
    #7
  8. Yes, this does the trick. Thanks to you all for your input !!

    Regards,
    Tony
     
    Tony Van De Velde, Dec 14, 2004
    #8
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.