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
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?
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.