jfklimek Posted November 8, 2012 Posted November 8, 2012 (edited) I'm having trouble finishing this LISP. Can anyone help me out. The command line is telling me the command I'm entering 'roomtag' is unknown. It's probably something little but I can't seem to figure it out. Please help out if you can. Thanks! ;;;Place Room Tag in Middle of Room and Auto Fill 'x' and 'y' Attribute Values (defun c:RoomTag (/ pt1 pt3 rx ry pt5) (initget 1) (setq pt1 (getpoint "\nFirst Corner: ")) (initget 1) (setq pt3 (getcorner "\nOpposite Corner: ")) (setq rx (abs (- (car pt3)(car pt1)))) (setq ry (abs (- (cadr pt3)(cadr pt1)))) (setq pt5 ((+ rx pt1) (- ry pt3))) (command "_INSERT" "Tag_Room-Dim" pt5 "" "" pause pause rx ry "") (princ) Edited November 12, 2012 by SLW210 Quote
Tharwat Posted November 8, 2012 Posted November 8, 2012 One issue .... (setq pt5 ([b]list [/b](+ rx pt1) (- ry pt3))) I think you should add one more parenthesis at the end of the routine . Quote
jfklimek Posted November 8, 2012 Author Posted November 8, 2012 (edited) [i][size=2];;;Place Room Tag in Middle of Room and Auto Fill 'x' and 'y' Attribute Values[/size][/i] [i][size=2](defun c:RoomTag (/ pt1 pt3 rx ry pt5)[/size][/i] [i][size=2](initget 1)[/size][/i] [i][size=2](setq pt1 (getpoint "\nFirst Corner: "))[/size][/i] [i][size=2](initget 1)[/size][/i] [i][size=2](setq pt3 (getcorner pt1 "\nOpposite Corner: "))[/size][/i] [i][size=2](setq rx ((- (car pt3)(car pt1))))[/size][/i] [i][size=2](setq ry ((- (cadr pt3)(cadr pt1))))[/size][/i] [i][size=2](setq pt5 (list (+ rx pt1) (+ ry pt1)))[/size][/i] [i][size=2](command "_INSERT" "Tag_Room-Dim" pt5 "" "" pause pause "abs rx "x" abs ry" " ")[/size][/i] [i][size=2](princ)[/size][/i] [i][size=2])[/size][/i] Thanks Tharwat, That got it off the ground. But now after I click the other corner of the room it gives me a 'bad function: 186.25'. I think I need to clarify. I am trying to pick two opposite corners to a room and have the lisp automatically put in a block with attributes I've created and fill the 'room dimensions' value of the block with (x'-x'' x y'-y''). The little 'x' between the two dimensions values is plain text. So I also need to find out how to get the values it is giving me for the distances and convert them to architectural equivalents... 186.25 = 15'-6 1/4". And secondly I would like it to round to the nearest whole number. Thanks for any other help. Edited November 12, 2012 by SLW210 Quote
Tharwat Posted November 8, 2012 Posted November 8, 2012 You have extra parenthesis in the two lines , one for the variable rx and one for ry . You receive bad function because the numbers must be strings ( i am saying that without testing it ) . Quote
pBe Posted November 9, 2012 Posted November 9, 2012 Note: With the command method, you need to consider the way "Tag_Room-Dim" is created (for scale) , ATTREQ & ATTDIA current Value (defun c:RoomTag (/ pt1 pt3 rx ry pt5) [b][color="blue"] (setq atrq (getvar 'attreq) atd (getvar 'attdia) ) (setvar 'Attreq 1) (setvar 'attdia 0)[/color][/b] (initget 1) (setq pt1 (getpoint "\nFirst Corner: ")) (initget 1) (setq pt3 (getcorner pt1 "\nOpposite Corner: ")) (setq rx (- (car pt3) (car pt1))) (setq ry (- (cadr pt3) (cadr pt1))) ;(setq pt5 (list (+ rx pt1) (+ ry pt1))) (command "_INSERT" "Tag_Room-Dim" [b][color="blue"] "_scale" "1"[/color][/b] [b][color="blue"](polar pt1 (angle pt1 pt3) (* (distance pt1 pt3) 0.5))[/color][/b] "" [color="blue"][b](strcat (rtos rx 4 0) "x" (rtos ry 4 0))[/b][/color] ) [b][color="blue"] (setvar 'Attreq atrq) (setvar 'attdia atd)[/color][/b] (princ) ) Quote
SLW210 Posted November 9, 2012 Posted November 9, 2012 jfklimek, Please read the CODE POSTING GUIDELINES and edit your posts to include CODE TAGS! Quote
Tharwat Posted November 9, 2012 Posted November 9, 2012 Error trap to re-set the user settings would be very helpful and safer Quote
jfklimek Posted November 9, 2012 Author Posted November 9, 2012 jfklimek, Please read the CODE POSTING GUIDELINES and edit your posts to include CODE TAGS! roger that SLW210. I tried to go back and change the code I put previously in but it says I don't have privelages to make those changes. This will be adhered to from now on. I apologize. Quote
jfklimek Posted November 9, 2012 Author Posted November 9, 2012 pBe, Thanks! So I'll make this short since the passed three replies were erased because it took to long for me to reply! ahhh. The code works, but I have to rearrange the three attributes in the block in order for the 'strcat' value to auto place. (It only auto places in the first attribute option). If it's not in the first attribute option, the following code skips any user input for the attributes entirely and places the 'strcat in the first value. (command "_INSERT" "Tag_Room-Dim" "_scale" "1" (polar pt1 (angle pt1 pt3) (* (distance pt1 pt3) 0.5)) "" pause pause (strcat (rtos rx 4 0) "x" (rtos ry 4 0)) ) Ideally I'd like to have the attributes arrange so that it prompts me for the first two attribute values then auto fills the last one with 'strcat'. Is this possible? The following code works with a rearrange block as spoken of above! (defun c:RoomTag\ (/ pt1 pt3 rx ry pt5) (setq atrq (getvar 'attreq) atd (getvar 'attdia) ) (setvar 'Attreq 1) (setvar 'attdia 0) (initget 1) (setq pt1 (getpoint "\nFirst Corner: ")) (initget 1) (setq pt3 (getcorner pt1 "\nOpposite Corner: ")) (setq rx (- (car pt3) (car pt1))) (setq ry (- (cadr pt3) (cadr pt1))) (command "_INSERT" "Tag_Room-Dim" "_scale" "1" (polar pt1 (angle pt1 pt3) (* (distance pt1 pt3) 0.5)) "" (strcat (rtos rx 4 0) "x" (rtos ry 4 0)) ) (setvar 'Attreq atrq) (setvar 'attdia atd) (princ) ) Quote
BIGAL Posted November 10, 2012 Posted November 10, 2012 Have the code auto fill all attributes. After picking the two corners then ask for the two attributes it will accept a if you want blank entry. This way insert pt scale rot att1 att2 att3 no worry then about pausing. (setq pt3 (getcorner pt1 "\nOpposite Corner: ")) (setq att1 (getstring "\nEnter att1")) (setq att2 (getstring "\nEnter att2")) Quote
jfklimek Posted November 10, 2012 Author Posted November 10, 2012 Thanks BIGAL! So I've completed this Lisp how I'd like it to work. Thanks for all the help peoples! The lisp is below and the block is attached for anyone that wants to use! ;;;RTAG (defun c:RTAG\ (/ pt1 pt3 rx ry pt5) (setq atrq (getvar 'attreq) atd (getvar 'attdia) ) (setvar 'Attreq 1) (setvar 'attdia 0) (initget 1) (setq pt1 (getpoint "\nFirst Room Corner: ")) (initget 1) (setq pt3 (getcorner pt1 "\nOpposite Room Corner: ")) (setq att1 (getstring "\nEnter Room Name Top")) (setq att2 (getstring "\nEnter Room Name")) (setq rx (abs (- (car pt3) (car pt1)))) (setq ry (abs (- (cadr pt3) (cadr pt1)))) (command "_INSERT" "Tag_Room-Dim" "_scale" "1" (polar pt1 (angle pt1 pt3) (* (distance pt1 pt3) 0.5)) "" att1 (strcat "%%U" att2) (strcat (rtos rx 4 0) "x" (rtos ry 4 0)) (setvar 'Attreq atrq) (setvar 'attdia atd) (princ) ) Tag_Room-Dim.dwg Quote
SLW210 Posted November 12, 2012 Posted November 12, 2012 roger that SLW210. I tried to go back and change the code I put previously in but it says I don't have privileges to make those changes. This will be adhered to from now on. I apologize. Select "Go Advanced" at the lower right of the reply box, they code tag button (#) should be there or alternately, add the tags yourself . (no space between the E and the bracket) I fixed your post this time. 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.