Jump to content

Recommended Posts

Posted

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)
)

Posted

LISP seems to be written extremely badly - I will try to rewrite.

Posted

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.

Posted

im getting the same result. Ive attached the block. thanks for the help

Drawing3.dwg

Posted

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.

Posted

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.

Posted

nvm i fixed it. my block wasnt at 0,0 in the origional dwg i moved it and now it works perfectly thanks!

Posted

Excellent - thought it would be the block being the issue about the insertion point.

 

Glad you got it working ok. :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...