AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Valued Contributor
newautocad123
Posts: 58
Registered: ‎09-03-2012
Message 1 of 4 (339 Views)

Add fields to existing object data : .net

339 Views, 3 Replies
10-29-2012 11:21 PM

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.

*Expert Elite*
norman.yuan
Posts: 1,062
Registered: ‎04-27-2009
Message 2 of 4 (328 Views)

Re: Add fields to existing object data : .net

10-31-2012 06:44 AM 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.

Active Member
huiz
Posts: 7
Registered: ‎01-16-2007
Message 3 of 4 (317 Views)

Re: Add fields to existing object data : .net

11-01-2012 06:27 AM 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?

Active Member
huiz
Posts: 7
Registered: ‎01-16-2007
Message 4 of 4 (312 Views)

Re: Add fields to existing object data : .net

11-01-2012 07:13 AM 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)

 

 

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.