Jump to content

Automatically Update Title block lisp HELP!


Millsy29

Recommended Posts

Hi everyone,

 

i have a lisp routine that i would like to alter to become more automated.

 

;* -------------------------- SUBROUTINE ------------------------------

(defun NEWSYSTEM ()

(cond

((= tagname "DRGNUM")(setq newdata drawingno))

((= tagname "CADFILE")(setq newdata cadfile))

((= tagname "REV")(setq newdata rev))

(T nil)

)

)

;* -------------------------- MAIN PROGRAM ------------------------------

 

(defun C:UPN (/ cadfile cadfilelen drawingno drawingrev drawingrevlen

rev field savefilename tagname newdata)

(setq cadfile (getvar "DWGNAME"))

(setq cadfilelen (strlen cadfile))

(setq drawingno (substr cadfile 1 (- cadfilelen 6)))

(setq drawingrev (substr cadfile 1 (- cadfilelen 4)))

(setq drawingrevlen (strlen drawingrev))

(setq rev (substr drawingrev drawingrevlen))

(setq field (entget (car (nentsel))))

(setq savefilename (cdr (assoc 1 field)))

(setq tagname (cdr (assoc 2 field)))

(NEWSYSTEM)

(setq field (subst (cons 1 newdata) (assoc 1 field) field))

(entmod field);modify database

(entupd (cdr (caddr field)));update entity without regen

(princ)

)

 

this allows me to select the title block attributes and change accordingly to the file name. (not trying to teaching you to suck eggs)

 

Now what i want it to do as all the title block is to search for block "A0-Sheet" "A1-Sheet" "A3-Sheet" then find "cadfile" attribute and automatically change and so of for the drawing no. and rev.

 

Can anybody help me with this?

 

Millsy

Link to comment
Share on other sites

Haven't got anything to test it on...

 

(defun c:upn ( / ss )
 ;; © Lee Mac 2010

 (if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "A#-Sheet") (66 . 1))))
   (
     (lambda ( i / file l dwg rev e el )
       (setq file (getvar 'DWGNAME) l (strlen file))

       (setq dwg (substr file 1 (- l 6))
             rev (substr file (- l 4) 1))

       (while (setq e (ssname ss (setq i (1+ i))))
         (while
           (not
             (eq "SEQEND"
               (cdr
                 (assoc 2
                   (setq el
                     (entget
                       (setq e
                         (entnext e)
                       )
                     )
                   )
                 )
               )
             )
           )
           (cond
             (
               (eq "DRGNUM" (cdr (assoc 2 el)))

               (Update (SubstDXF 1 dwg el))
             )
             (
               (eq "CADFILE" (cdr (assoc 2 el)))

               (Update (SubstDXF 1 file el))
             )
             (
               (eq "REV" (cdr (assoc 2 el)))

               (Update (SubstDXF 1 rev el))
             )
           )
         )
       )
     )
     -1
   )
 )

 (princ)
)

(defun SubstDXF ( code value elist )
 ;; © Lee Mac 2010
 (entmod
   (subst
     (cons code value) (assoc code elist) elist
   )
 )
)

(defun Update ( elist )
 ;; © Lee Mac 2010
 (entupd
   (cdr (assoc -1 elist))
 )
)

Link to comment
Share on other sites

it works the cad file changes and drawing no. changes but the rev comes out as - instead of A could this be its looking at the wrong part of the file name?

 

Example file name below:

302039-01M0201-003-A.dwg

 

Also this comes up at the end????

 

; error: An error has occurred inside the *error* functiontoo many arguments

Link to comment
Share on other sites

it works the cad file changes and drawing no. changes but the rev comes out as - instead of A could this be its looking at the wrong part of the file name?

 

Example file name below:

302039-01M0201-003-A.dwg

 

Also this comes up at the end????

 

; error: An error has occurred inside the *error* functiontoo many arguments

 

Yeah, I was about to ask for an example filename actually :)

 

Not sure about the *error* - that is something to do with an unlocalised error handler in another routine you are running as mine does not have an error handler.

 

Updated code.

Link to comment
Share on other sites

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