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.
Solved! Go to Solution.
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
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?
A, found the solution. After adding new definitions you need to update the tables collection.
myTables.UpdateTable(myTable.Name, myTable.FieldDefinitions)
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.