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

Obtain Default Value of an Attribute Definition

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Millerni456
570 Views, 1 Reply

Obtain Default Value of an Attribute Definition

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

1 REPLY 1
Message 2 of 2
Millerni456
in reply to: Millerni456

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

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