Hi there,
The below lisp is used to modify selected block attribute.
(vl-string-subst "" "B" string),
(vl-string-subst "" "b" string),
(wcmatch attribute_string "#[AaBb]"),
(wcmatch attribute_string "##[AaBb]")
in the above setting, block attribute will be change from 1B to 1
(vl-string-subst "B" "A" string),
(vl-string-subst "b" "a" string),
(wcmatch attribute_string "#[AaBb]"),
(wcmatch attribute_string "##[AaBb]")
in the above setting, block attribute will be change from 1A to 1B
(vl-string-subst "" "C" string),
(vl-string-subst "" "c" string),
(wcmatch attribute_string "#[AaCc]"),
(wcmatch attribute_string "##[AaCc]")
in the above setting, block attribute will be change from 1C to 1
Could you please modify the lisp to change block attribute from 1 to 1C?
Please see the lisp below, the original lisp was 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 "" "B" string)
)
(
(= (car (reverse (vl-string->list string))) 97)
(vl-string-subst "" "b" string)
)
)
)
;********************************************************************************************
(setq data_assoc_list '(
("DATE" . "2024MAY")
; ("DESIGNED_BY" . "P. SINGH")
; ("INDEPENDENT_CHK" . "R. CLELLAND")
; ("DRAFTED_BY" . "M. RU")
; ("DRAFTING_CHECK" . "P. SINGH")
)
)
(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,BCH-X-BORD-REVI-TRIA,BCH-X-ANNO-STMP-OBSO,REVTRIANGLE")
(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 "#[AaBb]")
(setq attribute_string (substr attribute_string 1 1)) ; keep only #
(vla-put-textString attribute attribute_string)
)
((wcmatch attribute_string "##[AaBb]")
(setq attribute_string (substr attribute_string 1 2)) ; keep only ##
(vla-put-textString attribute attribute_string)
)
) ; cond
)
)
)
)
(
(or
(= "BCH-ST-DYN-DWG-ISSUE" (vla-get-effectivename block_reference))
(= "B-BCH-ST-DYN-DWG-ISSUE" (vla-get-effectivename block_reference))
)
(setpropertyvalue (vlax-vla-object->ename block_reference) "AcDbDynBlockPropertyVisibility" "IFC - ISSUE FOR CONSTRUCTION")
)
(
t
)
)
(vlax-release-object block_reference)
)
)
(princ)
)