A Little Problem with OSNAP

Roderic Potter

Usenet Archive
Joined
Jan 23, 2004
Messages
20
Reaction score
0
Please take a look at the following pice of (probably inefficient) code:

(setq ee1 (entsel "\nPick centrepoint of text: "))
(setq ee (car ee1))
(if ee
(progn
(setq e (entget ee))
(setq n (cdr (assoc 8 e)))
(setq pt1 (cadr ee1))
(command "LAYER" "SET" n "")
))

Here I am trying to do a number of things at once - pick an entity, capture its layer, and save the point coordinates of the actual pick. I would like to use an OSNAP "Near" in the entsel operation, and I would like this to be automatic. It makes no difference what the current setting of OSNAP is when this code is run, you are merely presented with a pickbox on the screen with no OSNAP to help you. You can call OSNAP Near on the fly during the entsel operation, but I would like this to be automatic.

I tried adding OSNAP to the entsel line of code, but kept getting "too many arguments" errors.

How can I invoke "Near" during the "entsel"?

thanks!
 
(setq e (entsel "\nPick entity near desired point: "))
(setq near_pt (osnap (cadr e) "qui,nea"))
 
Thanks for this Tony, but it has no effect on the original entsel command on-screen - there is still nothing but a pickbox, with no running OSNAP to help you pick the line.
 
Looking for something like this?

(setq o-osmode (getvar "osmode"))
(setvar "osmode" 512)
(setq a (getpoint))
(setq ent (nentselp a))
(setvar "osmode" o-osmode)
 
Roderic,

You cannot use the (osnap) function inside the entsel command. You can, however use the (osnap) function on the point after returning it. Ex:

(setq ee1 (entsel "\nPick centrepoint of text: "))
(setq ee (car ee1))
(if ee
(progn
(setq e (entget ee))
(setq n (cdr (assoc 8 e)))
(setq pt1 (cadr ee1))

;; CODE ADDED HERE - Causes the point picked to snap to nearest point. (if (setq pt (osnap pt1 "nea")) (setq pt1 pt) (princ "\n Error - No nearest point found!")
)

(command "LAYER" "SET" n "")
))
 
Ahh... I need to refresh my newsreader more frequently. Anyway Ken's solution is what you have to use to change the running osnap while prompting.
 

Latest threads

Back
Top