LISP2LEARN Posted June 8, 2012 Posted June 8, 2012 Hi guys, Is it possible to use (entsel) as (getpoint). My goal is to select a block and get it's insertion point and if it nil or I click on a blank area it will just get the point on where I click and missed. Thank you. Quote
pBe Posted June 8, 2012 Posted June 8, 2012 (edited) with entsel , select the object , (cdr (assoc 10 (entget object))); If you're wanting the prompt to conitnue when you "missed" (if (not (while (progn (setvar 'errno 0) (setq en (car (entsel))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (eq 'ename (type en)) (if (not (eq (cdr (assoc 0 (entget en))) "INSERT")) (princ "\nInvalid Object Selected.") ) ) ) ) ) ) (cdr (assoc 10 (entget en)))) kudos to Lee Mac et al Edited June 8, 2012 by pBe Quote
LISP2LEARN Posted June 8, 2012 Author Posted June 8, 2012 Thank you Pbe but that is not my goal. If I missed, then I just need to get the point on where I clicked. It's either get the insertion point of a block or get the point on where I missed when I click. If you're wanting the prompt to conitnue when you "missed" Quote
BlackBox Posted June 8, 2012 Posted June 8, 2012 For completeness, getting the second item in the list returned by Entsel is the point of selection, which is not the same as the insertion point of a block. One could easily evaluate if a block is returned by Entsel, if so returning the insertion point, and if not then return the point of selection. Quote
Stefan BMR Posted June 8, 2012 Posted June 8, 2012 Maybe this (defun sel_block ( / p1 s e) (if (setq p1 (getpoint "\nSelect block: ")) (if (setq s (nentselp p1)) (if (and (eq (type (setq e (car (cadddr s)))) 'ENAME) (eq (cdr (assoc 0 (entget e))) "INSERT") ) (cdr (assoc 10 (entget e))) (progn (princ "\nNot a block") (sel_block) ) ) p1 ) ) ) (defun C:TEST () (sel_block) ) Quote
pBe Posted June 8, 2012 Posted June 8, 2012 Thank you Pbe but that is not my goal. If I missed, then I just need to get the point on where I clicked. It's either get the insertion point of a block or get the point on where I missed when I click. Thing with entsel, when you "missed" you wont get anything at all. You can however use grread (if (or (setq ent (entsel)) (setq gr (grread t 15 0) code (car gr))) (setq pt (if ent (cdr (assoc 10 (entget (Car ent)))) (cadr gr))) ) Ooops Quote
LISP2LEARN Posted June 8, 2012 Author Posted June 8, 2012 Thanks Stefan and pBe your code is exactly what I'm looking for. I've spend half a day to figure this out to no avail. Thanks again! pBe, Just wondering, what is the purpose of the "code" variable? Thing with entsel, when you "missed" you wont get anything at all.You can however use grread (if (or (setq ent (entsel)) (setq gr (grread t 15 0) [color="red"]code (car gr)[/color])) (setq pt (if ent (cdr (assoc 10 (entget (Car ent)))) (cadr gr))) ) Ooops Quote
pBe Posted June 8, 2012 Posted June 8, 2012 Pbe, Just wondering, what is the purpose of the "code" variable? Cool beans Pay no attention to it. its a left-over from the routine i copied the snippet. Anyways FYI (= 5 code) ;; Mouse has been dragged (= 2 code) ;; Keyboard has been pressed (= 3 code) ;; Left-Click of the mouse HTH Quote
Recommended Posts
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.