How to get selected sketch segment ID and points

Jul 09, 2003 1 Replies

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


get our

formatting link
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 -

formatting link

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required