How to get selected sketch segment ID and points

Discussion in 'SolidWorks' started by John Smith, Jul 9, 2003.

  1. John Smith

    John Smith Guest

    I have what I think should be a simple question. I have an open sketch
    and a line selected. I want to:

    1) Get the ID of the line so I can get back to it later. I've found
    code to loop through all of the sketch segments and get their IDs but
    that doesn't help me because I don't know which ones they are. I need
    to get the ID of the selected line only.

    2) Get the start and end points of the line in x and y coordinates. I
    found GetStartPoint and GetEndPoint but can't figure out how to use
    them.

    To me this should be very simple and maybe it is, but I can't seem to
    find anything explaining how to do it. Any help will be most
    appreciated.

    john smith
     
    John Smith, Jul 9, 2003
    #1
  2. get our http://www.dynabits.com/sw/spliner.htm free, open-source add-in.
    In the source you'll find an undocumented, unofficial but working trick to
    get the ID of a sketch segment:
    the second number of the SketchSegment::GetID result is the number that
    follows the segment type.
    This being said, I strongly advise to avoid using SelectByID, and use
    SketchSegment::Select instead.
    GetStartPoint and GetEndPoint return SketchPoint objects, which have X,Y,Z
    properties

    Philippe Guglielmetti - www.dynabits.com
     
    Philippe Guglielmetti, Jul 10, 2003
    #2
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.