Hi everyone,
This should hopefully be a straightforward task in AutoCAD .NET, but I'm having trouble figuring it out.
My objective is to look at all attribute definitions within a block definition, and then store the tags and default values into a dictionary.
So far I've successfully extracted the tag string, yet I cannot find how to access the default value of the attribute definition.
Here is a snippet of code that builds the dictionary of attributes:
//Iterate through all entities in the block definition.
BlockTableRecord blockDefinition = tr.GetObject(blockTable[blockName], OpenMode.ForRead) as BlockTableRecord; Dictionary<String, String> attributes = new Dictionary<String, String>(); foreach (ObjectId entId in blockDefinition) { Entity entity = tr.GetObject(entId, OpenMode.ForRead) as Entity; if (entity != null) { //If the entity is an attribute definition, append its information to the dictionary above. if (entity is AttributeDefinition) { AttributeDefinition attributeDefinition = entity as AttributeDefinition; attributes.Add(attributeDefinition.Tag, INSERT ATTRIBUTE'S DEFAULT VALUE HERE); } } }
Does anyone know how to retreive the attribute definitions default value?
Thanks much,
Nick
Solved! Go to Solution.
Solved by Millerni456. Go to Solution.
Solved.
I was testing on bad data earlier in which attribute tags were the same as their default values. Because of this, I didn't see that my previously correct code was indeed correct.
To obtain the default value, retrieve this property:
AttributeDefintion.TextString