VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to place text into block attribute using vba?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
robert.kulas
629 Views, 5 Replies

How to place text into block attribute using vba?

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

5 REPLIES 5
Message 2 of 6
MakCADD
in reply to: robert.kulas

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

Message 3 of 6
robert.kulas
in reply to: robert.kulas

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?

 

Message 4 of 6
Ed.Jobe
in reply to: robert.kulas

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

Message 5 of 6
MakCADD
in reply to: Ed.Jobe

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.

Message 6 of 6
robert.kulas
in reply to: robert.kulas

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

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

Post to forums  

Autodesk Design & Make Report

”Boost