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

Adding a AttributeReference to a block

1 REPLY 1
Reply
Message 1 of 2
mabe2k11
333 Views, 1 Reply

Adding a AttributeReference to a block

Hello!

I have a problem with adding attributeReferences to a blockReference.
I use the following lines to add the attribute (see attachment for the full method):

...
AttributeDefinition attDef = new AttributeDefinition(new Point3d(0d, 0d, 0d), "TestValue", "AttName", "", db.Textstyle);
btrBlock.AppendEntity(attDef);
trans.AddNewlyCreatedDBObject(attDef, true);
...
AttributeReference attRef = new AttributeReference();
attRef.SetAttributeFromBlock(attDef, blockRef.BlockTransform);
blockRef.AttributeCollection.AppendAttribute(attRef);
blockRef.AttributeCollection.
...

After running the method no error occurs, but when I want to edit the attributes of the block (dubleklick on it), I get the following AutoCAD-Exception:
!AcEAttedit.cpp@403: eWasOpenForWrite

When I continue drawing, ACAD2006 crashes completely.
I spend hours with this problem, but I still haven't found why this error appears. Ok, the error shows me that something ist still open, and should be closed - but what?
1 REPLY 1
Message 2 of 2
mabe2k11
in reply to: mabe2k11

Sorry, I got it!

I found it in the Autodesk .net-Labs:

AttributeReference attRef = new AttributeReference();
attRef.SetAttributeFromBlock(attDef, blockRef.BlockTransform);
blockRef.AttributeCollection.AppendAttribute(attRef);
trans.AddNewlyCreatedDBObject(attRef, true);

I add the last line and it works great.

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