How to highlight a rectangle by clicking inside it

How to highlight a rectangle by clicking inside it

mecoman6GF27
Advocate Advocate
715 Views
5 Replies
Message 1 of 6

How to highlight a rectangle by clicking inside it

mecoman6GF27
Advocate
Advocate

Hi everyone.

As per the title of the post I would like to ask you if it is possible to highlight and not select the sides of a rectangle by clicking inside it as if SELECTIONEFFECT were set to 0.

Thank you all very much, bye.

0 Likes
716 Views
5 Replies
Replies (5)
Message 2 of 6

norman.yuan
Mentor
Mentor

Your requirement is actually a 2-stage task:

1. after user clicks somewhere in the editor, you need to find of if it is enclosed by a boundary, be it a single entity/rectangle, circle..., or be a boundary formed by multiple entities. However, if your code somehow already knows which entity (a rectangle polyline, for example), then obviously there is not need for user to click inside of it.

 

2. Once you find out the boundary, you then decide how to "highlight" it. If it is a single entity, you can simply call Entity.Highlight() method. If it is the boundary formed by multiple entities, you may need to draw the tempotatry boundary, using, for example, Transient graphics.

 

You can call Editor.TraceBoundary() method to find out the enclosing boundary of a point. The method returns a DBObjectCollection containing non-database-residing entities. You can use them to drawing Transient graphics. these links should be very helpful:

 

https://www.keanw.com/2010/06/tracing-a-boundary-defined-by-autocad-geometry-using-net.html 

https://www.keanw.com/2012/09/creating-reactive-transient-autocad-geometry-using-net.html 

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 6

mecoman6GF27
Advocate
Advocate

Hello and thanks for the help.

Bye.

0 Likes
Message 4 of 6

norman.yuan
Mentor
Mentor

Well, I have an article on using Editor.TraceBoundary() to test an enclosed area and highlight it with mouse move. Not exactly what you need, but you can certainly get some idea from it:

 

https://drive-cad-with-code.blogspot.com/2023/02/prompting-area-by-moving-mouse-cursor.html 

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 6

mecoman6GF27
Advocate
Advocate

HI.
Really very interesting! But I would like to ask you: why is the start and end point of the polyline highlighted with a circle if the mouse is not over a closed area?
Thanks a lot, bye.

0 Likes
Message 6 of 6

norman.yuan
Mentor
Mentor

In the article I pointed out the annoying command line message generated by Editor.TraceBoundary(), which might be the mistake left behind by Autodesk's programmers of forgetting to clean up some debugging/testing auxiliary code, I also guess the red circles you noticed (of course I saw them when I run the code) are due to the same reason. There is other explanation, because my code does none of them.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes