Jump to content

Hello friends , need help !


DuanJinHui

Recommended Posts

Hello friends.

 

(setq pt1 (cadr (entsel "\nPick the obj:")))

Above code can get point coordinates , is no pick anything will returns "nil"

 

I want , if no pick anything still returns the Pick Points coordinates , like function (getpoint) .

 

Any good idea ?

Link to comment
Share on other sites

 

I want , if no pick anything still returns the Pick Points coordinates , like function (getpoint) .

 

Any good idea ?

 

Then why don't you use GETPOINT function.

Link to comment
Share on other sites

Maybe this :)

 

(if (not (setq pt1 (cadr (entsel "\nPick the obj:"))))
 (setq pt1 (cadr (grread t 15 0)))
)

 

Thank you very much , Tharwat. very good !

Link to comment
Share on other sites

You are most welcome .

 

Hi Mr.Tharwat.

(setq pt1 (cadr (entsel "\nPick the obj:"))),

above code have a small defects.

coordinate precision is constraints by ZOOM

 

eg.

one horizontal line , x coordinate is "0.0" , I use (setq pt1 (cadr (entsel "\nPick the obj:"))) pick on this line :

 

result: (18.8774 -0.00995981 0.0)

 

Zoom Out...

test again ,the result is: (20.8111 0.0871873 0.0)

 

Is there a way to solve ?

Link to comment
Share on other sites

Use a combination of getpoint/nentselp

 

Thanks Lee,

you mean like this :

(if	(and (setq p (getpoint "\nSelect: "))
(setq e (cadr(nentselp p)))
)
e
p
)

 

But I fell do it like this , No difference with

only (setq p (getpoint "\nSelect: "))

Link to comment
Share on other sites

I'm not sure what you are trying to achieve -

 

getpoint will allow the user to accurately specify a point with Object Snaps available; you can then use the selected point to obtain the entity located at point using either nentselp or ssget.

 

If you want an inaccurate point specification, but a point which lies on a selected entity, use the vlax-curve-getclosestpointto function in conjunction with the point & entity returned by entsel. This will return a point on the selected entity which is nearest to the center of the pickbox aperture.

Link to comment
Share on other sites

If you want an inaccurate point specification, but a point which lies on a selected entity, use the vlax-curve-getclosestpointto function in conjunction with the point & entity returned by entsel. This will return a point on the selected entity which is nearest to the center of the pickbox aperture.

 

Many Thanks ! Lee, can you give an example ?

Link to comment
Share on other sites

For example:

(if (setq sel (entsel))
   (list (car sel) (vlax-curve-getclosestpointto (car sel) (trans (cadr sel) 1 0)))
)

Or:

(if (setq pnt (getpoint "\nPick a point: "))
   (if (setq sel (nentselp pnt))
       (list (car sel) (vlax-curve-getclosestpointto (car sel) (trans (cadr sel) 1 0)))
       pnt
   )
)

Link to comment
Share on other sites

For example:

(if (setq sel (entsel))
   (list (car sel) (vlax-curve-getclosestpointto (car sel) (trans (cadr sel) 1 0)))
)

Or:

(if (setq pnt (getpoint "\nPick a point: "))
   (if (setq sel (nentselp pnt))
       (list (car sel) (vlax-curve-getclosestpointto (car sel) (trans (cadr sel) 1 0)))
       pnt
   )
)

 

Thanks Lee, very useful!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...