chelsea1307 Posted January 7, 2009 Posted January 7, 2009 Ive been going through all the old lisp files and have narrowed down the lisps we have from over 170 to 60, this one has a good concept it just doesnt work all the way. It insterts out room name block after taking the area (used for area takeoffs) and it asks for room name line 1 and 2 and room number after entering the informationb it inserts, but without the area, room name and room number that was just inserted. What isnt right and how do I fix it. I dont know alot about lisps i can barely read them and havent created my own before. (DEFUN C:ARE () (IF (TBLSEARCH "LAYER" "ROOMNAMES" ) (PROGN (SETQ RGN (GETVAR "REGENMODE" )) (SETVAR "REGENMODE" 0) (COMMAND "LAYER" "M" "DESIGN") (COMMAND "C" "1" "") (COMMAND "") (COMMAND "LAYER" "S" "ROOMNAMES" "") (SETVAR "REGENMODE" RGN) );PROGN ); IF (SETQ AR2 (ENTSEL "\N PICK AREA")) (COMMAND "AREA" "E" AR2 ) (SETQ AR (GETVAR "AREA")) (SETQ AR1 (/ AR 144 )) (SETQ AR2 (RTOS AR1 2 1)) (SETQ SCL (GETVAR "DIMSCALE")) (SETQ PNT (GETPOINT "\ N PICK INSERTION POINT:")) (SETQ NME (GETSTRING "\ N ENTER ROOMNAME LINE#2")) (SETQ NME2 (GETSTRING "\ N ENTER ROOMNAME LINE #1")) (SETQ NME3 (GETSTRING "\ N ENTER NUMBER")) (COMMAND "INSERT" "ROOM" PNT SCL SCL "0" NME NME2 NME3 AR2) ) Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 LISP seems to be written extremely badly - I will try to rewrite. Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 Thats the LISP written better: (defun c:ARE (/ *error* varlist oldvars ar2 ar scl pnt nme2 nme nme3) (defun *error* (msg) (mapcar 'setvar varlist oldvars) (if (= msg "") (princ "\nFunction Complete.") (princ (strcat "\n" (strcase msg))) ) ;_ end if (princ) ) ;_ end defun (setq varlist (list "CMDECHO" "ATTREQ" "CLAYER" "OSMODE") oldvars (mapcar 'getvar varlist) ) ;_ end setq (mapcar 'setvar varlist (list 0 1 "0" 0)) (if (not (tblsearch "LAYER" "ROOMNAMES")) (command "-layer" "m" "ROOMNAMES" "C" "1" "ROOMNAMES" "") (setvar "clayer" "ROOMNAMES") ) ; if (while (not ar2) (setq ar2 (car (entsel "\nPick Area: "))) ) ;_ end while (command "_area" "object" ar2) (setq ar (rtos (/ (getvar "AREA") 144) 2 1) scl (getvar "dimscale") ) ;_ end setq (if (and (setq pnt (getpoint "\nPick insertion point:") nme2 (getstring "\nEnter Roomname Line #1: ") nme (getstring "\nEnter Roomname Line #2: ") nme3 (getstring "\nEnter Number: ") ) ;_ end setq ) ;_ end and (command "-insert" "room" pnt scl scl "0.0" nme nme2 nme3 ar) ) ;_ end if (*error* "") (princ) ) ;_ end defun If that does not work properly, supply the block you are using and I will test. Quote
chelsea1307 Posted January 7, 2009 Author Posted January 7, 2009 im getting the same result. Ive attached the block. thanks for the help Drawing3.dwg Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 Ok, Use this code: (defun c:ARE (/ *error* varlist oldvars ar2 ar scl pnt nme2 nme nme3) (defun *error* (msg) (mapcar 'setvar varlist oldvars) (if (= msg "") (princ "\nFunction Complete.") (princ (strcat "\n" (strcase msg))) ) ;_ end if (princ) ) ;_ end defun (setq varlist (list "CMDECHO" "ATTREQ" "CLAYER" "OSMODE") oldvars (mapcar 'getvar varlist) ) ;_ end setq (mapcar 'setvar varlist (list 0 1 "0" 0)) (if (not (tblsearch "LAYER" "ROOMNAMES")) (command "-layer" "m" "ROOMNAMES" "C" "1" "ROOMNAMES" "") (setvar "clayer" "ROOMNAMES") ) ; if (while (not ar2) (setq ar2 (car (entsel "\nPick Area: "))) ) ;_ end while (command "_area" "object" ar2) (setq ar (rtos (/ (getvar "AREA") 144) 2 1) scl (max 1 (getvar "dimscale")) ) ;_ end setq (if (and (setq pnt (getpoint "\nPick insertion point:") nme2 (getstring t "\nEnter Roomname Line #1: ") nme (getstring t "\nEnter Roomname Line #2: ") nme3 (getstring t "\nEnter Number: ") ) ;_ end setq ) ;_ end and (command "-insert" "room" pnt scl scl "0.0" nme nme2 nme3 ar) ) ;_ end if (*error* "") (princ) ) ;_ end defun And in your block dwg, explode the block and purge the block out of the drawing, then save as room.dwg in the ACAD library search path and it will work. Quote
chelsea1307 Posted January 8, 2009 Author Posted January 8, 2009 that almost works perfectly. for some reason though it doesnt insert at the insertion point its off by about a foot and a half. how do i fix that? i notice when i select the block it has a grip at the insertion point, if that helps to know why its inserting off. Quote
chelsea1307 Posted January 8, 2009 Author Posted January 8, 2009 nvm i fixed it. my block wasnt at 0,0 in the origional dwg i moved it and now it works perfectly thanks! Quote
Lee Mac Posted January 8, 2009 Posted January 8, 2009 Excellent - thought it would be the block being the issue about the insertion point. Glad you got it working ok. 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.