.NET

.NET

Reply
Valued Contributor
Millerni456
Posts: 55
Registered: ‎01-23-2013
Message 1 of 2 (225 Views)
Accepted Solution

Obtain Default Value of an Attribute Definition

225 Views, 1 Replies
03-18-2014 06:04 AM

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.

 

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

Valued Contributor
Millerni456
Posts: 55
Registered: ‎01-23-2013
Message 2 of 2 (214 Views)

Re: Obtain Default Value of an Attribute Definition

03-18-2014 06:36 AM 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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.