Select segment line of polyline on screen like in FILLET command

Select segment line of polyline on screen like in FILLET command

Anonymous
Not applicable
2,076 Views
4 Replies
Message 1 of 5

Select segment line of polyline on screen like in FILLET command

Anonymous
Not applicable

Hello everyone,

 

I would like to ask how it is possible with VBA in AutoCad to select one segment line of a polyline on screen like you do it for example in the FILLET command, where you can select single lines, even if they are part of a polyline.

 

I couldn't find a way to do it with the "ThisDrawing.Utility.GetEntity" method. Maybe there is a way by using AcadSelectionSet.SelectOnScreen?

 

Thanks in advance,

Michael

Accepted solutions (2)
2,077 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor
Accepted solution

AutoCAD VBA/COM API is not capable of doing it.

 

However, it can be done with AutoCAD .NET APIs (if you planed to move on to AutoCAD .NET APIs from VBA, this would be another reason 🤔). In case you are curious on how to do it with .NET API and the visual effect, see this article:

 

https://drive-cad-with-code.blogspot.com/2019/02/visually-select-segment-of-polyline.html

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5

Anonymous
Not applicable

Thank you for your fast reply. It's a pity, that this is not possible with VBA.

Do you think, that it would be a practical way to create a copy of the polyline, explode it and then ask the user to pick one of these lines?

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor
Accepted solution

That is a good idea of workaround.

 

I think, the main purpose of selecting a segment of a polyline (let's make it simple: AcadLWPolyline) is to know the coordinates of 2 vertices of the segment from the polyline, right? So, another workaround would be like:

 

1. Before calling AcadUtility.GetEntity() to ask user to pick a polyline, turn on ObjectSnap's "NEAREST" bit, so that the picked point returned by GetEntity() would be actually fall right on the polyline;

2. Do calculation to compare the picked point with each vertex of the polyline to eventually determine between which 2 vertices the picked point is. At this moment, the programming task is achieved (knowing which segment is selected); but you likely want to provide visual hint to user, so,

3. Using the 2 vertices to create a Line with different color (or highlight it, or both); Just to make sure that you erase the line at some point of your code execution, so you do not leave garbage behind.

 

It is messy workaround, but maybe slightly better than explode the polyline and create a whole bunch of lines, most of which may never be needed.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 5

Anonymous
Not applicable

Thats a good Idea! I think I'll go with that.

Thanks!

0 Likes