.NET

.NET

Reply
Contributor
24 Posts
0 Kudos
Registered: ‎03-14-2006
Post 1 of 2

Adding a AttributeReference to a block

174 Views, 1 Replies
05-13-2006 06:49 AM
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?
Contributor
24 Posts
0 Kudos
Registered: ‎03-14-2006
Post 2 of 2

Re: Adding a AttributeReference to a block

05-14-2006 04:20 AM 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.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!