AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Valued Contributor
58 Posts
0 Kudos
Registered: ‎09-03-2012
Post 1 of 4

Add fields to existing object data : .net

344 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*
1,088 Posts
217 Kudos
Registered: ‎04-27-2009
Post 2 of 4

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
7 Posts
0 Kudos
Registered: ‎01-16-2007
Post 3 of 4

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
7 Posts
0 Kudos
Registered: ‎01-16-2007
Post 4 of 4

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
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!