Author Topic: Problem determine PickedPoint on selected object  (Read 160 times)

0 Members and 1 Guest are viewing this topic.

Sieu khung khiep

  • Mosquito
  • Posts: 5
Problem determine PickedPoint on selected object
« 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.
« Last Edit: November 06, 2019, 04:51:21 AM by Sieu khung khiep »

n.yuan

  • Bull Frog
  • Posts: 278
Re: Problem determine PickedPoint on selected object
« Reply #1 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.

Sieu khung khiep

  • Mosquito
  • Posts: 5
Re: Problem determine PickedPoint on selected object
« Reply #2 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:

BIGAL

  • Bull Frog
  • Posts: 345
  • 30 + years of using Autocad
Re: Problem determine PickedPoint on selected object
« Reply #3 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[
A man who never made a mistake never made anything