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

Issue with Block Attributes.

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
PSharpe
755 Views, 3 Replies

Issue with Block Attributes.

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.SetAttributeFromBlock(attDef, newBlockReference.BlockTransform)

attColl.AppendAttribute(attRef)

attRef.TextString = "SOMETHING"

currentTransaction.AddNewlyCreatedDBObject(attRef, True)

End If

Next

 

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.

e.g.

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.

 

3 REPLIES 3
Message 2 of 4
PSharpe
in reply to: PSharpe

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

Message 3 of 4
caddzone
in reply to: PSharpe

Don't create an AttributeReference for constant attribute definitions.



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 4 of 4
PSharpe
in reply to: caddzone

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!!

 

Problem solved.

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost