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

Attribute Definition

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
797 Views, 3 Replies

Attribute Definition

Hi,

 

I created a block with 2 attribute fields. But I am not sure how can i set the values of each field. Anybody can help?

By using the textstring of attribute reference each field is set with the same value "Test" as shown below.

 

Dim RefBTR As BlockTableRecord = trans.GetObject(blkmh.BlockTableRecord, OpenMode.ForRead)
                Dim attEnt As Entity

                For Each attID As ObjectId In RefBTR
                    attEnt = trans.GetObject(attID, OpenMode.ForRead)
                    If TypeOf attEnt Is AttributeDefinition Then
                        Dim attDef As AttributeDefinition = attEnt
                        Dim attRef As AttributeReference = New AttributeReference()
                        attRef.SetAttributeFromBlock(attDef, blkmh.BlockTransform)
                        Dim attRefID As ObjectId
                        attRefID = blkmh.AttributeCollection.AppendAttribute(attRef)
                        attRef.TextString = "Test"

                        trans.AddNewlyCreatedDBObject(attRef, True)
                    End If
                Next

3 REPLIES 3
Message 2 of 4
chiefbraincloud
in reply to: Anonymous

Well, as long as blkmh is a proper BlockReference object, what you've got there should do it.  What specifically is the problem you're having?

Dave O.                                                                  Sig-Logos32.png
Message 3 of 4
Anonymous
in reply to: Anonymous

Your post refers to each 'field'.

 

What exactly do you mean by 'field' ? 

Message 4 of 4
Anonymous
in reply to: Anonymous

Hi,

 

Sorry for that. I found what I was looking for. I was new to the attributes and because of ignorance that query was raised. My intention was how can we add the attribute data to the block once inserted into drawing if more than one attribute definition is there. I understand that the code listed will do all at a time.

 

Thanks for your support.

 

Prajith.

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report