Is it possible to change the Constant property of an AttributeReference ? (the property IsConstant is readonly)
How to set the Constant property AttributeReference?
1.6k Views Asked by Florian At
2
There are 2 best solutions below
0

You need to change the AttributeDefinition
in the block table record (property Constant
), not on the AttributeReference
. This property is shared with all the AttributeReference
.
From the docs:
AutoCAD itself never creates a constant AttributeReference object. AutoCAD creates the AttributeReference objects for each BlockReference based on the AttributeDefinition objects within the referenced BlockTableRecord. If a constant AttributeDefinition is encountered, then AutoCAD uses the AttributeDefinition itself instead of creating a matching AttributeReference.
I don't know about objectarx, but in .Net (since you stated c#), try this:
Edit: I just realized you also said AttributeReference and not AttributeDefinition. Without verifying for sure, I think the reference cannot be modified directly since the value is constant. Because of this, you'll have to update the block's definition in the BlockTableRecord, same basic process once you've got it.
Here's the code for updating: