AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add fields to existing object data : .net

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
newautocad123
1763 Views, 5 Replies

Add fields to existing object data : .net

It is possible to add fields to the existing object data in a dwg file, with .net. Please suggest the way to add field to existing object data, if it is possible.

 

Thanks.

5 REPLIES 5
Message 2 of 6
norman.yuan
in reply to: newautocad123

Yes, it is possible using managed Map API:

 

Look into Autodesk.Gis.Map.ObjectData.FieldDefinitions.Add()/AddColumn() method.

 

In case you have not used managed MAp API:

 

1. In an Acad plug-in DLL project, set reference to ManagedMapApl.dll;

2. Write code to identify the target object data table

3. Create a FieldDefinition object;

4. Call Table.FieldDefinitions.AddColumn(myField)

5 If necessary, find all entities that has the target table record attached, and set value for the newly added field.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 6
huiz
in reply to: norman.yuan

I've tried adding new field definitions to an existing table but it does not work. While debugging the code runs well, I don't get exceptions but the new field definition is not added.

 

 

myTable.FieldDefinitions.AddColumn(FieldDefinition.Create("Name", "Desc", "", myTable.FieldDefinitions.Count)

 

 

Do I need to update or commit something after this?

Message 4 of 6
huiz
in reply to: huiz

A, found the solution. After adding new definitions you need to update the tables collection.

 

  myTables.UpdateTable(myTable.Name, myTable.FieldDefinitions)

 

 

Message 5 of 6

Thanks for posting this - just solved my issue. Should be marked as a solution.



Steve Hill
Civil Designer / .NET Developer
AutoCAD Certified Professional
AutoCAD Civil 3D Certified Professional
http://redtransitconsultants.com/
Autodesk Exchange Store
Twitter | LinkedIn



Please select the Accept this solution button if my post solves your issue or answers your question.

Message 6 of 6
MGO-Norsyn
in reply to: huiz

A "Thank you" from the future for this solution!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost