Code:
(defun C:UpdateTB
(/ inspt atts acsp fname
issuenum revnum tddate issuedfor
amblk adoc
)
(vl-load-com)
(setvar "cmdecho" 0)
(setq zero (list 0 0 0))
(setq adoc (vla-get-activedocument
(vlax-get-acad-object)
) ;_ end of vla-get-activedocument
) ;_ end of setq
(if (and
(= (getvar "tilemode") 0)
(= (getvar "cvport") 1)
) ;_ end of and
(setq acsp (vla-get-paperspace adoc))
(setq acsp (vla-get-modelspace adoc))
) ;_ end of if
(setq fname
"S:\\DSA CAD\\BLOCK'S\\Dynamic Blocks\\Set Up\\Attributes\\Ammendment Line.dwg"
) ;_ end of setq
;;Enter the directory path and file name of ammendment tag to be inserted
(setq atblk "title")
;;Sets the name of the title block attribute to be ammended
(setq revtag "[A]")
;;Sets the name of the REV tag to be ammended (setq revnum (strcase (getstring "What REV is the drawing?.."))) to prompt user
(setq datetag "26.11.08")
;;Sets the date of the ammendment tag, use (menucmd "M=$(edtime,$(getvar,date),DD.MO.yy)") to automate days date
(setq issuedfortag "Drawing Issued For .......")
;;Sets the what the drawing is to be issued for (setq issuedfor (getstring T "Drawing Issued For .......")) from user prompts
(setq drawntag (strcase "##"))
;;Sets the name of the DRAWN tag to be ammended (setq drawntag (strcase (getstring "Who has DRAWN the drawing?..))) to prompt user
(setq engineertag (strcase "##"))
;;Sets the name of the ENGINEER tag to be ammended (setq engineertag (strcase (getstring "Which ENGINEER designed the drawing?.."))) to prompt user
(setq checkedtag (strcase "##"))
;;Sets the name of the CHECKED tag to be ammended (setq checkedtag (strcase (getstring "Who CHECKED the drawing?.."))) to prompt user
(setq approvedtag (strcase "##"))
;;Sets the name of the APPROVED tag to be ammended (setq approvedtag (strcase (getstring "Who APPROVED the drawing?.."))) to prompt user
(vla-startundomark
(vla-get-activedocument (vlax-get-acad-object))
) ;_ end of vla-startundomark
(if (findfile ammendln)
(progn
(setq amblk (vlax-invoke acsp 'Insertblock zero fname 1 1 1 0))
(setq atts (vlax-invoke amblk 'GetAttributes))
(foreach at atts
(cond
((eq "ISSUE" (vlax-get at 'TagString))
(vlax-put at 'TextString issuenum)
)
((eq "REV" (vlax-get at 'TagString))
(vlax-put at 'TextString revtag)
)
((eq "DATE" (vlax-get at 'TagString))
(vlax-put at 'TextString datetag)
)
((eq "AMMENDMENT" (vlax-get at 'TagString))
(vlax-put at 'TextString issuefortag)
)
) ;_cond
) ;_foreach
(vla-update amblk)
(alert
"Ammendment Block Was Not Found\nCheck it is in the AutoCAD Search Path"
) ;_ end of alert
) ;_ end of progn
) ;_if
;;; I think i have an error here. I am trying to search for the block and if found proceed.
(if (= (tblsearch "block" atblk))
(progn
(setq atts (vlax-invoke atblk 'GetAttributes))
(foreach at atts
(cond
((eq "DRAWN" (vlax-get at 'TagString))
(vlax-put at 'TextString drawntag)
)
((eq "ENGINEER" (vlax-get at 'TagString))
(vlax-put at 'TextString engineertag)
)
((eq "CHECKED" (vlax-get at 'TagString))
(vlax-put at 'TextString checkedtag)
)
((eq "APPROVED" (vlax-get at 'TagString))
(vlax-put at 'TextString approvedtag)
)
((eq "DATE" (vlax-get at 'TagString))
(vlax-put at 'TextString datetag)
)
;| This section here is of concern. I need to read the tag "NUMBER"and then trim the number (hence my first start of thread).
To
my
understanding
this
will
place
the
value
of
numbertag
in
the
attributed
tag.|;
((eq "NUMBER" (vlax-get at 'TagString))
(vlax-put at 'TextString numbertag)
)
((eq "AA" (vlax-get at 'TagString))
(vlax-put at 'TextString revnum)
)
) ;_cond
) ;_foreach
(vla-update atblk)
(alert
"Title, Attributed Block Was Not Found\nCheck the block name is correct and in drawing"
) ;_ end of alert
) ;_ end of progn
) ;_if
(vla-regen adoc acactiveviewport)
(vla-endundomark
(vla-get-activedocument (vlax-get-acad-object))
) ;_ end of vla-endundomark
(command "-layout" "rename" "" revnum)
(princ)
) ;_ end of defun
I took care of a couple of the errors with the too many arguments, when using an if statement, if you have more than one function that you want to run, you must use include the functions within (progn ... )