Skip to content

Instantly share code, notes, and snippets.

@rudderdon
Created August 30, 2016 17:56
Show Gist options
  • Save rudderdon/d8880c26253634b1a2908c14726f3367 to your computer and use it in GitHub Desktop.
Save rudderdon/d8880c26253634b1a2908c14726f3367 to your computer and use it in GitHub Desktop.
Autolisp to Update Titleblock Attributes
(defun c:magic ()
(setq osm (getvar "OSMODE"))
(setq attq (getvar "ATTREQ"))
(setvar "OSMODE" 0)
(setvar "ATTREQ" 0)
(command "-xref" "p" "TbInfo-CP51" "..\\..\\Blks\\TbInfo.dwg")
(doRevs)
(doSheet)
(command "-layer" "thaw" "*|E-REVS-SIGN-1" "on" "*|E-REVS-SIGN-1" "")
(setvar "OSMODE" osm)
(setvar "ATTREQ" attq)
)
(defun doRevs ()
(setq ss (ssget "x" '((0 . "INSERT") (2 . "ATTRIBUTE-BLOCK-NAME"))))
(setq i 0)
(if (/= ss nil)
(progn
(if (/= nil (ssname ss i))
(progn
(setq ent (entget (ssname ss i)))
(setq p1 (cdr (assoc 10 ent)))
(setq blk (ssname ss i))
(setq entx (entget (entnext (cdr (assoc -1 ent)))))
(while (= "ATTRIB" (cdr (assoc 0 entx)))
(setq value (cdr (assoc 2 entx)))
(if (= value "REV-NO-1")
(progn
(setq a (cons 1 "0"))
(setq b (assoc 1 entx))
(entmod (subst a b entx))
)
)
(if (= value "REV-NO-1-DATE")
(progn
(setq a (cons 1 "17.03.10"))
(setq b (assoc 1 entx))
(entmod (subst a b entx))
)
)
(if (= value "REV-1-DESCRIPTION")
(progn
(setq a (cons 1 "ISSUED FOR XXXXXXXXXXXXXXXXXX"))
(setq b (assoc 1 entx))
(entmod (subst a b entx))
)
)
(if (= value "REV-NO-2")
(progn
(setq a (cons 1 "1"))
(setq b (assoc 1 entx))
(entmod (subst a b entx))
)
)
(if (= value "REV-NO-2-DATE")
(progn
(setq a (cons 1 "15.09.10"))
(setq b (assoc 1 entx))
(entmod (subst a b entx))
)
)
(if (= value "REV-2-DESCRIPTION")
(progn
(setq a (cons 1 "ISSUED FOR XXXXXXXXXXXXXXXXX"))
(setq b (assoc 1 entx))
(entmod (subst a b entx))
)
)
****************************************************************************************
(setq entx (entget (entnext (cdr (assoc -1 entx)))))
)
(entupd blk)
(setq i (+ 1 i))
)
)
(prompt "Attribute updated successfully. ")
)
)
(princ)
)
(defun doSheet ()
(setq ss (ssget "x" '((0 . "INSERT") (2 . "BLOCK NAME"))))
(setq i 0)
(if (/= ss nil)
(progn
(if (/= nil (ssname ss i))
(progn
(setq ent (entget (ssname ss i)))
(setq p1 (cdr (assoc 10 ent)))
(setq blk (ssname ss i))
(setq entx (entget (entnext (cdr (assoc -1 ent)))))
(while (= "ATTRIB" (cdr (assoc 0 entx)))
(setq value (cdr (assoc 2 entx)))
(if (= value "REV-NO")
(progn
(setq a (cons 1 "1"))
(setq b (assoc 1 entx))
(entmod (subst a b entx))
)
)
(if (= value "PROJECT-JOB-NO")
(progn
(setq a (cons 1 ""))
(setq b (assoc 1 entx))
(entmod (subst a b entx))
)
)
****************************************************************************************
(setq entx (entget (entnext (cdr (assoc -1 entx)))))
)
(entupd blk)
(setq i (+ 1 i))
)
)
(prompt "Attribute updated successfully. ")
)
)
(princ)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment