Here is a place to start.
The syntax is
Code:
(TitleBlockValue strBlockname strTagString)
and it will return the textstring value of the first attribute with the specified tagstring in the first instance of the strBlockName block
P=
Code:
;___________________________________________________________________________________________________________|
;
; Written By: Peter Jamtgaard copyright 2017 All Rights Reserved
;___________________________________________________________________________________________________________|
;
; Abstract: This set of functions are designed to get an attribute textstring from the first instance of a
; (or selected) block reference i
;___________________________________________________________________________________________________________|
;
; Command Line Function Header List
;___________________________________________________________________________________________________________|
;* C:TitleBlockValue
;* Command Line Function to get a value from a block reference and a tagstring (test function)
;___________________________________________________________________________________________________________|
;
; General Function Header List
;___________________________________________________________________________________________________________|
; Function, Arguments and Description
;* (AttributeSublists objBlockReference)
;* Function to create a list of sublists from a block reference of its attribute tagstring, textstring and handle
;* (AttributeTextString objSelection strTagString)
;* Function to get a textstring value from a block reference and a tagstring
;* (TitleBlockValue strBlockname strTagString)
;* Function to get a value from the first instance of a block reference
;$ End Header
;___________________________________________________________________________________________________________|
;
; Command line Function to get an attribute value from a selected block and entered attribute tagstring.
;___________________________________________________________________________________________________________|
(defun C:TitleBlockValue (/ entSelection objSelection ssSelections strTagString)
(if (and (princ "\nSelect Title Block: ")
(setq ssSelections (ssget ":S:E" (list (cons 0 "INSERT")(cons 66 1))))
(setq strTagString (getstring "\nEnter TagString: "))
(setq entSelection (ssname ssSelections 0))
(setq objSelection (vlax-ename->vla-object entSelection))
)
(AttributeTextString objSelection strTagString)
)
)
;___________________________________________________________________________________________________________|
;
; Function to create a list of sublists from a block reference of its attribute tagstring, textstring and handle
;___________________________________________________________________________________________________________|
(defun AttributeSublists (objBlockReference / lstAttributes objAttribute)
(if (and (vlax-method-applicable-p objBlockReference "getattributes")
(setq lstAttributes (vlax-invoke objBlockReference "getattributes"))
)
(setq lstOfSublists (mapcar '(lambda (objAttribute)(list (strcase (vla-get-tagstring objAttribute))
(vla-get-textstring objAttribute)
(vla-get-handle objAttribute)
)
)
lstAttributes
)
)
)
)
;___________________________________________________________________________________________________________|
;
; Function to get a textstring value from a block reference and a tagstring
;___________________________________________________________________________________________________________|
(defun AttributeTextString (objSelection strTagString)
(if (setq lstOfSublists (AttributeSublists objSelection))
(cadr (assoc (strcase strTagString) lstOfSublists))
)
)
;___________________________________________________________________________________________________________|
;
; Function to get a value from the first instance of a block reference
;___________________________________________________________________________________________________________|
(defun TitleBlockValue (strBlockname strTagString / entSelection objSelection ssSelections)
(if (and (setq ssSelections (ssget "x" (list (cons 2 strBlockName)(cons 66 1))))
(setq entSelection (ssname ssSelections 0))
(setq objSelection (vlax-ename->vla-object entSelection))
)
(AttributeTextString objSelection strTagString)
)
)
(princ "!")
(vl-load-com)