I have some code which is inserting a block with attributes and setting the TextString property as the block is inserted. (This works appart from this issue)
Dim attColl As AttributeCollection = newBlockReference.AttributeCollection
Dim entID As ObjectId
Dim ent As Entity
For Each entID In newBlockDef
ent = entID.GetObject(OpenMode.ForRead)
If TypeOf ent Is AttributeDefinition Then
Dim attDef As AttributeDefinition = CType(ent, AttributeDefinition)
Dim attRef As New AttributeReference
attRef.TextString = "SOMETHING"
When the block is inserted and the attributes are set using this code, double clicking on the block in the drawing and examining the attributes in the "Enhanced Attribute Editor" the prompt values for the attributes are all mixed up.
The block definition has multiple attributes with prompt text entered against them in the block definition.
Tag: DEVICE, PROMPT:"Enter Device Reference", VALUE:"AMMETER"
Tag: PART#, PROMPT: "Enter Actual Part #", VALUE:"E242-75A"
After the insert using the above code the Prompt might appear like this:
Tag: DEVICE, PROMPT:"Default Mounting Location", VALUE:"AMMETER"
Tag: PART#, PROMPT: "Enter Device Reference", VALUE:"E242-75A"
It appears as though the prompt text is being set as the prompt text from the previous attribute whenever it is empty.
FYI if the block is inserted manually using the AutoCAD insert command the attribute definitions are correct so i have to assume im doing something wrong here.
Any help would be appreciated.
Solved! Go to Solution.
A little more information this appears to be tied in with constant attributes as this code appears to be making constant attributes editable so im definatley doing somehting wrong here
I just figured that out and have resolved this issue. The problem i had was that i was checking the IsConstant attribute of the AttributeReference (as you say) rather than the Constant attribute of the AttributeDefinition before deciding how to process it.
Spent hours going round with this one for it to be so simple!!
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register