.NET

Reply
Contributor
mabe2k11
Posts: 24
Registered: ‎03-14-2006
Message 1 of 2 (172 Views)

Adding a AttributeReference to a block

172 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
mabe2k11
Posts: 24
Registered: ‎03-14-2006
Message 2 of 2 (172 Views)

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
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.