Hi,
I wonder if the below changes can be made to the current lisp?
1. The current lisp remove letter from the attribute of the blocks, for example, "1A", it will be changed to "1".
I want to add "1" to current attribute value, for example, if the current value is "2", the new value will be "3". The following blocks and respectively tag will be changed.
block names are BCH-X-BORD-DXXX, BCH-X-BORD-BXXX, BCH-X-BORD-AXXX, BCH-X-BORD-REVI, BCH-X-BORD-REVI-TRIA, BCH-X-ANNO-STMP-OBSO
attribute tag is REV_`#, R_NO, R_NO_D&E, R_NO_A&B, REV_NO
2. add one layer to the DWG, layer name: $X-ANNO-REVC-ELEC, color: 220
Please see the lisp below, the lisp file and one DWG file with blocks were attached as well, thank you very much in advance. 🙂
(vl-load-com)
(defun c:ASet (/ format_date chgtxt adoc data_assoc_list ss attribute_tag attribute_string)
;********************************************************************************************
(defun format_date (/ mon date)
(setq mon '("JAN" "FEB" "MAR" "APR" "MAY" "JUN" "JUL" "AUG" "SEP" "OCT" "NOV" "DEC"))
(setq date (rtos (fix (getvar "cdate")) 2 0))
(strcat (substr date 1 4) (nth (1- (atoi (substr date 5 2))) mon) (substr date 7 2))
)
;********************************************************************************************
(defun chgtxt (string)
(cond
(
(= (car (reverse (vl-string->list string))) 65)
(vl-string-subst "" "A" string)
)
(
(= (car (reverse (vl-string->list string))) 97)
(vl-string-subst "" "a" string)
)
)
)
;********************************************************************************************
(setq data_assoc_list '(
("DATE" . "2023AUG25")
)
)
(if (ssget "_X" (list '(0 . "insert")))
(vlax-for block_reference (vla-get-activeSelectionSet (vla-get-activedocument (vlax-get-acad-object)))
(cond
(
(wcmatch (strcase (vla-get-effectiveName block_reference)) "BCH-X-BORD-DXXX,BCH-X-BORD-BXXX,BCH-X-BORD-AXXX,BCH-X-BORD-REVI-TRIA,BCH-X-ANNO-STMP-OBSO")
(foreach attribute (vlax-invoke block_reference 'getAttributes)
(setq attribute_tag (strcase (vla-get-tagString attribute)))
(setq attribute_string (vla-get-textString attribute))
(cond
(
(setq item (assoc attribute_tag data_assoc_list))
(vla-put-textString attribute (format_date))
(vla-put-textString attribute (cdr item))
)
(
(wcmatch attribute_tag "REV_`#,R_NO,R_NO_D&E,R_NO_A&B,REV_NO")
(cond
((wcmatch attribute_string "#[AaAa]")
(setq attribute_string (substr attribute_string 1 1)) ; keep only #
(vla-put-textString attribute attribute_string)
)
((wcmatch attribute_string "##[AaAa]")
(setq attribute_string (substr attribute_string 1 2)) ; keep only ##
(vla-put-textString attribute attribute_string)
)
) ; cond
)
)
)
)
(
(= "BCH-ST-DYN-DWG-ISSUE" (vla-get-effectivename block_reference))
(setpropertyvalue (vlax-vla-object->ename block_reference) "AcDbDynBlockPropertyVisibility" "IRD - ISSUE RECORD DRAWING")
)
(
t
)
)
(vlax-release-object block_reference)
)
)
(vl-cmdf "_.Layer" "_F" "$X-ANNO-REVC" "") ; freeze layer "$X-ANNO-REVC"
(princ)
)