Okay, let's start here.
Command CTA (for Change Titleblock Attributes) to start the function
This selects the the title block on the current Layout,
then asks the user to fill in LTSHTDESC and LTSHTNUM.
;; Load Visual Lisp
(vl-load-com)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lee Mac, read and set attributes:
;; @see http://www.lee-mac.com/attributefunctions.html
;; Get Attribute Value - Lee Mac
;; Returns the value held by the specified tag within the supplied block, if present.
;; blk - [vla] VLA Block Reference Object
;; tag - [str] Attribute TagString
;; Returns: [str] Attribute value, else nil if tag is not found.
(defun LM:vl-getattributevalue ( blk tag )
(setq tag (strcase tag))
(vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes))
)
;; Get Attribute Values - Lee Mac
;; Returns an association list of attributes present in the supplied block.
;; blk - [ent] Block (Insert) Entity Name
;; Returns: [lst] Association list of ((<tag> . <value>) ... )
;; http://www.lee-mac.com/attributefunctions.html#algetattributevaluerc
(defun LM:getattributevalues ( blk / enx )
(if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk))))))
(cons
(cons
(cdr (assoc 2 enx))
(cdr (assoc 1 (reverse enx)))
)
(LM:getattributevalues blk)
)
)
)
;; Set Attribute Value - Lee Mac
;; Sets the value of the first attribute with the given tag found within the block, if present.
;; blk - [vla] VLA Block Reference Object
;; tag - [str] Attribute TagString
;; val - [str] Attribute Value
;; Returns: [str] Attribute value if successful, else nil.
(defun LM:vl-setattributevalue ( blk tag val )
(setq tag (strcase tag))
(vl-some
'(lambda ( att )
(if (= tag (strcase (vla-get-tagstring att)))
(progn (vla-put-textstring att val) val)
)
)
(vlax-invoke blk 'getattributes)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun cgange_titleblock ( / ss blk)
;; select the title block on current layout.
;; (getvar "ctab") returns the current layout. The block keeps this information in: (assoc 410 blk)
(setq ss (ssget "_X" (list (cons 0 "insert") (cons 2 "Titleblock_Properties_22x34") (cons 410 (getvar "ctab")) )) )
(setq blk (ssname ss 0))
;;
;;(LM:vl-setattributevalue (vlax-ename->vla-object blk) "LTSHTDESC" "Detail 1 - Detail 15")
(LM:vl-setattributevalue (vlax-ename->vla-object blk) "LTSHTDESC" (getstring "\nLTSHTDESC: " T))
;;(LM:vl-setattributevalue (vlax-ename->vla-object blk) "LTSHTNUM" "D-1")
(LM:vl-setattributevalue (vlax-ename->vla-object blk) "LTSHTNUM" (getstring "\nLTSHTNUM: " T))
)
;; Type command CTA (for Change Titleblock Attributes) to start the function
(defun c:cta ( / )
(cgange_titleblock)
(princ)
)
What more would you like the function to do?
More can be automated of course.
For example, we could make a list
(list
(list "Sheet1" "Detail 1 - Detail 15" "D-1")
(list "Sheet1" "Detail 2 - Detail 15" "D-2")
(list "Sheet1" "Detail 3 - Detail 15" "D-3")
;; ...
)
... then the function fills in everything ...