Jump to content
Millsy29

Automatically Update Title block lisp HELP!

Recommended Posts

Millsy29

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

Share this post


Link to post
Share on other sites
Lee Mac

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

Share this post


Link to post
Share on other sites
Millsy29

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

Share this post


Link to post
Share on other sites
Lee Mac
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.

Share this post


Link to post
Share on other sites
Millsy29

BEAUITFUL PATRICK!!!!

Max%2520%26%2520Paddy.jpg

:lol::lol::lol::lol::lol::lol::lol:

 

WORKS LIKE A CHARM!

 

thanks a million

 

Millsy

Share this post


Link to post
Share on other sites
Lee Mac

Excellent - nice one :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×