How prompt user select part of polyline

Anonymous

How prompt user select part of polyline

Anonymous
Not applicable

Hi all, 

 

I'm using construction

 

// Request for objects to be selected in the drawing area
            acSSPrompt = acDocEd.GetSelection(new PromptSelectionOptions
            {
                SingleOnly = true,
                ForceSubSelections = true
            });

two times and each time I'm selecting different parts of polyline , but Object Id for both selections are the same.

 

Why?

 

Thanks.

0 Likes
Reply
2,042 Views
7 Replies
Replies (7)

_gile
Mentor
Mentor

Hi,

 

ForceSubSelections is to be used to force the selection of 'sub-objects' such as faces, edges or vetices of Solid3d objects.

A Polyline (LWPOLYLINE) is a simple entity which does not have sub-objects.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

Anonymous
Not applicable

Hi Gile,

 

thank you for explanation.

 

In that case how prompt user select one arc as part of polyline?

 

Let's say, that single polyline is combination of 9 arcs. And user should select any from the arcs.

0 Likes

moogalm
Autodesk Support
Autodesk Support

Polyline is single entity, irrespective of where you click, you will ObjectId of the Polyline, of course user can use CTRL+Selection on Polyline, in that case only hovered entity get highlighted, but again you will get ObjectId of Polyline not the segments.

 

What is your objective, do you want operate on segments user has hovered?

0 Likes

norman.yuan
Mentor
Mentor

There is no direct API method(s) that you can call for your purpose. But one should be able to write code to achieve that, such as using DrawableOverrule, and/or Transient Graphics, or combination of them, and maybe, plus the handling of PointMonitor event. The code would be quite complicated, depending what kind of visual hints you want to lead user to select portion of the polyline. I'd imagine to code would:

 

1. Start handing PointMonitor event to detect whether the cursor is close/hover the polyline;

2. If yes, draw transient graphic on that portion of polyline (segment between 2 vertices, be it a straight line, or an arc, you should figure it out based on the polyline and the vertices). So, this transient graphic would serve as visual hint to user that certain portion of the polyline is to be selected.

3. If user click the mouse button (thus "select" this portion of polyline), you would update the transient graphic to indicates that (say, change its color, or make it thicker...)

 

This is just a rough idea. It might also be possible to write code to achieve the same visual effect as you do with Ctrl + select to the polyline. Again, this would required advanced coding skill with AutoCAD .NET APIs.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes

Anonymous
Not applicable

Hi Norman, 

 

thank you for detailed reply. For my task I did "explode" for Polyline and then user was able to work with list of arcs/lines.

 

0 Likes

ActivistInvestor
Advisor
Advisor

If you set PrepareOptionalDetails and SinglePickInSpace to true, then the GraphicsSystemMarker property of the SelectedObject should be the index of the selected Polyline vertex (I haven't actually confirmed that this works, but it seems logical that it should).

 

If the GraphicsSystemMarker property is zero, then you could find the index of the selected vertex using the pick point and the Curve's GetClosestPointTo() and GetParameterAtPoint() methods.

 

Mind you, either of these only give you index of the selected Polyline vertex.

 

 


@Anonymous wrote:

Hi Gile,

 

thank you for explanation.

 

In that case how prompt user select one arc as part of polyline?

 

Let's say, that single polyline is combination of 9 arcs. And user should select any from the arcs.


 

norman.yuan
Mentor
Mentor

OK, I found a bit time writing some code to materialize what I said in previous reply. I published the code with a video clips here:

 

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

 

Hope it helps.

 

 

Norman Yuan

Drive CAD With Code

EESignature