.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Block Attribute TAG Search & Replace

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
626 Views, 4 Replies

Block Attribute TAG Search & Replace

Does anyone have a net routine to find & replace attribute tags?
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

A while ago I required a similar function, but through LISP. I know this isn't a LISP board, but it may be a quick fix until you find a solution.

{code}
; ** Block Tag Renamer
(defun BLOCK_TAG_REPLACE (sBlock sPrompt sTag / EntName IAcadBlockReference2 AttObjLst IAcadBlock3 PromptString)
(vl-load-com)
;Locate the specified block name in the current tab
(setq ss1 (ssget "X"(list (cons 0 "INSERT")(cons 2 sBlock)(cons 410(getvar "CTAB")))))
(progn
;set the Entity Name to the first found block
(setq EntName (ssname ss1 0))
;Create a new reference of the block for attributes
(setq IAcadBlockReference2 (vlax-ename->vla-object EntName ) )
;If the block reference has attributes
(if (= (vla-get-hasattributes IAcadBlockReference2 ) :vlax-true )
;Create an array of the attributes
(setq AttObjLst (vlax-safearray->list (variant-value (vla-getattributes IAcadBlockReference2 ))) )
( )
)
;Create a new reference of the same block for the prompt strings
(setq IAcadBlock3 (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object ))) sBlock ) )
;For every attribute in our collection of attributes
(foreach Attrib AttObjLst
;Look for a prompt string
(vlax-for PromptString IAcadBlock3
;If prompt strings are found
(if (= (vla-get-objectname PromptString ) "AcDbAttributeDefinition" )
(progn
(if (= (vla-get-promptstring PromptString) sPrompt)
(progn
(if (= (vla-get-tagstring PromptString) (vla-get-tagstring Attrib))
(progn
(vla-put-tagstring PromptString sTag)
(vla-put-tagstring Attrib sTag)
)
)
)
)
)
)
)
)
)
)
{code}

The usage of the above is thus:
{code}
(BLOCK_TAG_REPLACE "BlockName" "CurrentPromptString" "NewTagValue" )
{code}
Message 3 of 5
Hallex
in reply to: Anonymous

This isn't you exactly need but it will be show you
the method to change properties of attributedefinition
(eg attribute prompt)
Same way for new attribute tag

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 5
Anonymous
in reply to: Anonymous

hallex

Could you also post the code that calls this function? I'd like to see how the blockreference variable is passed into this function. In particular the mechanism to figure out which blockreference to select.
Message 5 of 5
Hallex
in reply to: Anonymous

Sorry for the belating
I was busy

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost