jmerch Posted March 26, 2012 Posted March 26, 2012 I've searched around and can't find a complete answer for this. I want to simply insert a block to the endpoint the user picks. But I also want the block to change to the layer of the object where the user picked the endpoint. So I just want the user to have to pick the insertion point and from that point, get the layer of the object, and also use it as the block insertion point later in the LISP without the user having to pick it again. Here's what I have so far (without the beginning and end of LISP): (setq cmdecho (getvar "cmdecho")) (setvar "CMDECHO" 0) (setq clayer (getvar "clayer")) (setq osmode (getvar "osmode")) (setvar "OSMODE" 1) (setq Pick (entsel "\nPick Point")) (if(null Pick) (command "clayer") (setvar "CLAYER" (cdr (assoc 8 (entget (car Pick))))) ) (command "insert" "ISO-VTR" pause "" "" pause) (setvar "OSMODE" osmode) (setvar "CMDECHO" cmdecho) (setvar "CLAYER" clayer) I know I'm not thinking about something simple, hopefully someone can shine light on it. Thanks! Quote
MSasu Posted March 26, 2012 Posted March 26, 2012 How about: (if (setq Pick (entsel "\nPick Point")) (command "insert" "ISO-VTR" pause "" "" pause "_CHPROP" (entlast) "" "_LA" (cdr (assoc 8 (entget (car Pick)))) "") ) I will also change the selection prompter to something more relevant - you dont select a point there, but an entity. Regards, Mircea Quote
jmerch Posted March 26, 2012 Author Posted March 26, 2012 this is still requiring 2 point selections, isn't it? I'd need the point picked (preferrably endpoint of a line selected by user) to also be put in where the first "pause" is after the block insert. Quote
MSasu Posted March 26, 2012 Posted March 26, 2012 To use a point from the entity selected by user as insertion point for block should extract that information based on entity type; for line the endpoints are stored in DXF codes 10 and 11 (got with ENTGET); should compare the distances from those point to the selection point returned by ENTSEL to use which one is closer. To use a point as argument for block insertion: (command "insert" "ISO-VTR" (cadr Pick) "" "" pause) Regards, Mircea Quote
jmerch Posted March 26, 2012 Author Posted March 26, 2012 Ah, Thank you much! I was trying it with (getpoint). Quote
MSasu Posted March 26, 2012 Posted March 26, 2012 An example for lines: (if (setq Pick (entsel "\nPick Point")) (progn (setq listEnt (entget (car Pick)) selPoint (cadr Pick)) (cond ((member '(0 . "LINE") listEnt) ;;; line entity (if (< (distance (setq point1st (cdr (assoc 10 listEnt))) selPoint) (distance (setq point2nd (cdr (assoc 11 listEnt))) selPoint)) (setq blockPoint point1st) (setq blockPoint point2nd) ) ) [color=blue]; extend for other entity types[/color] ) (command "_INSERT" "ISO-VTR" blockPoint "" "" pause "_CHPROP" (entlast) "" "_LA" (cdr (assoc 8 (entget (car Pick)))) "") ) ) Regards, Mircea Quote
jmerch Posted March 26, 2012 Author Posted March 26, 2012 Got it, I'll play around with it. Thanks again! 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.