TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on February 29, 2024, 04:07:55 PM
Title:
Global Attribute Edit w/ Widcard
Post by:
GDF
on
February 29, 2024, 04:07:55 PM
I trying to use Peter's function with a wildcard to reset a tags value.
(AttributeStringSubst "SYMRM" "NOTE2"
wildcard
"")
Need help, please.
Code - Auto/Visual Lisp:
[Select]
;;;(AttributeStringSubst BlockName TagString OldText NewText)
;;;Peter Jamtgaard
(
defun
AttributeStringSubst
(
strBlockName strTagString
strPattern strNewString
/
strString
)
(
vlax-for
objLayout
(
vla-get-layouts
(
vla-get-activedocument
(
vlax-get-acad-object
)
)
)
(
vlax-for
objBlock
(
vla-get-block
objLayout
)
(
if
(
and
(
wcmatch
(
vla-get-objectname
objBlock
)
"AcDbBlockReference,AcDbMInsertBlock"
)
(
wcmatch
(
strcase
strBlockName
)
(
strcase
(
vla-get-name
objBlock
)
)
)
(
=
(
vla-get-hasattributes
objBlock
)
:vlax-true
)
)
(
foreach
objAttribute
(
vlax-invoke
objBlock
"getattributes"
)
(
setq
strString
(
vla-get-textstring
objAttribute
)
)
(
if
(
wcmatch
(
strcase
(
vla-get-tagstring
objAttribute
)
)
(
strcase
strTagString
)
)
(
if
(
not
(
vl-string-search
strPattern strNewString
)
)
(
progn
(
while
(
vl-string-search
strPattern strString
0
)
(
setq
strString
(
vl
-
string
-
subst
strNewString strPattern strString
)
)
)
(
vla-put-textstring
objAttribute strString
)
)
)
)
)
)
)
)
(
princ
)
)
Title:
Re: Global Attribute Edit w/ Widcard
Post by:
Lee Mac
on
February 29, 2024, 06:46:19 PM
Perhaps this can help Gary -
https://www.theswamp.org/index.php?topic=58363.msg615317#msg615317
Though, I'm unsure what you mean by 'reset' - do you mean revert to the default value held by the attribute definition?
Title:
Re: Global Attribute Edit w/ Widcard
Post by:
GDF
on
March 01, 2024, 08:40:37 AM
Thanks Lee...works perfectly!!!