PDA

View Full Version : Automatically Update Title block lisp HELP!



Millsy29
15th Jul 2010, 01:38 pm
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

Lee Mac
15th Jul 2010, 04:30 pm
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))
)
)

Millsy29
15th Jul 2010, 05:10 pm
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

Lee Mac
15th Jul 2010, 05:14 pm
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.

Millsy29
15th Jul 2010, 05:24 pm
BEAUITFUL PATRICK!!!!
http://t3.gstatic.com/images?q=tbn:IgefLhVLEgm7aM:http://www.freewebs.com/peterkaypics/Max%2520%26%2520Paddy.jpg (http://www.google.co.uk/imgres?imgurl=http://www.freewebs.com/peterkaypics/Max%2520%26%2520Paddy.jpg&imgrefurl=http://www.freewebs.com/peterkaypics/pictures.htm&usg=__lxPk9M_ehALXML2vFpqGIQ6k4r4=&h=600&w=800&sz=67&hl=en&start=1&itbs=1&tbnid=IgefLhVLEgm7aM:&tbnh=107&tbnw=143&prev=/images%3Fq%3DMAX%2BAND%2BPADDY%26hl%3Den%26safe%3D active%26sa%3DG%26gbv%3D2%26tbs%3Disch:1)
:lol::lol::lol::lol::lol::lol::lol:

WORKS LIKE A CHARM!

thanks a million

Millsy

Lee Mac
15th Jul 2010, 05:29 pm
Excellent - nice one :)