TheSwamp

Code Red => .NET => Topic started by: Sieu khung khiep on November 06, 2019, 03:51:47 AM

Title: Problem determine PickedPoint on selected object
Post by: Sieu khung khiep on November 06, 2019, 03:51:47 AM
Hello, I have just stepped into .Net and I am currently having difficulty determining the point I have just chosen on the Object (here is the circle)
I have read this post and I use the class DisplacementJig  to move the circle:

https://www.keanw.com/2013/12/moving-text-in-an-autocad-block-using-net-part-2.html

the problem is that when I select the circle, the point I just selected [Promptpoint.Pickedpoint] is not on the circle. so when I move the circle I won't get to the point I want
Can you guide me further?
thank you very much.
Title: Re: Problem determine PickedPoint on selected object
Post by: n.yuan on November 06, 2019, 09:29:38 AM
When you pick something in AutoCAD editor, AutoCAD provides you a PICK BOX, anything crossed by the pick box could be selected, and the PickedPoint property is the center of the pick box. So, as you already know, when the pick box picks an entity with its box edge, the box' center may not exactly on the picked entity. So, the PickedPoint property is just a reference of where exactly the pick box center is when user clicks. If you need a point that is exactly ON the picked entity, it is your responsibility found out where that point is.

Fortunately it is quite easy to do in most cases (when the picked entity is an entity derived from Curve: you can use Curve.GetClosestPoint([PickedPoint], false) to get it.
Title: Re: Problem determine PickedPoint on selected object
Post by: Sieu khung khiep on November 06, 2019, 06:12:20 PM
Hi  n.yuan! This tip really worked for me. I thought it works similar entsel in lisp.
Great forum! Thanks for the reply.   :smitten:
Title: Re: Problem determine PickedPoint on selected object
Post by: BIGAL on November 07, 2019, 06:44:43 PM
This may help

Code: [Select]
: PICKBOX
New current value for PICKBOX (0 to 50) <4>:20
: (entsel)
Select entity: (<Entity name: 5ab0f700> (282.566742146517 200.043918915706 0.0))
: (entsel)
Select entity: near
Snap to nearest of: (<Entity name: 5ab0f700> (273.046687118245 198.726333624194 0.0))
[/code[