How to place text into block attribute using vba?

How to place text into block attribute using vba?

robert.kulas
Contributor Contributor
1,489 Views
5 Replies
Message 1 of 6

How to place text into block attribute using vba?

robert.kulas
Contributor
Contributor

Hi,

how can I insert text into AutoCAD block attribute using VBA? I have the list of items in Excel with coordinates.

The macro is in Excel.

The blocks are placed but without text inside. I would appreciate for support. RK

0 Likes
Accepted solutions (1)
1,490 Views
5 Replies
Replies (5)
Message 2 of 6

MakCADD
Advocate
Advocate

easiest way is to export attribute values to csv file (attout) and open in excel and replace the data with new value and import (attin) file again in the drawing

 

vba

attribute=block.getattributes

attribute(index).textstring=newvalue

0 Likes
Message 3 of 6

robert.kulas
Contributor
Contributor

Thank you MakCADD for the answer.

It should be done by VBA (part of solution) why I try to implement nothing changed. The attribute inside block (item name) stay empty.

Could you send me any example?

 

0 Likes
Message 4 of 6

Ed__Jobe
Mentor
Mentor

It would help if you showed the code you have so far. You also need to know the tag name of the attribute you want to change if there's more than one attribute in the block reference.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 6

MakCADD
Advocate
Advocate
Accepted solution
For each object in thisdrawing.layouts(layout.name).block
  If typeof object is acadblockreference then
    Set blockref=object
    If blockref.name= "ABCD" then
      Attr=blockref.getattributes
      For I=0 to ubound(attr)
        If attr(I).tagstring="aaaa" then attr(I).textstring="zzzz"
      Next I
    End if
  End if
Next object

 

Moderator edit: Put code into code window using </> button.

0 Likes
Message 6 of 6

robert.kulas
Contributor
Contributor

Thank you very much for help. The issue was solved.

0 Likes