Creating a Table
- Creating an ObjectData.FieldDefinitions object
- Adding field definitions for every column in the table
- Creating the table by adding the field definitions to the ODTables object for the drawing
Create an ObjectData.FieldDefinitions object using the ProjectModel.MapUtility.NewODFieldDefinitions() method. Add fields using the FieldDefinitions.Add() method. For example, if mapApp is the Map application, the following creates field definitions for 2 columns:
Dim fieldDefs As ObjectData.FieldDefinitions
fieldDefs = _
mapApp.ActiveProject.MapUtility.NewODFieldDefinitions()
Dim def1 As ObjectData.FieldDefinition
def1 = fieldDefs.Add("FIRST_FIELD", "Owner name", _
Autodesk.Gis.Map.Constants.DataType.Character, 0)
def1.SetDefaultValue("A")
Dim def2 As ObjectData.FieldDefinition
def2 = fieldDefs.Add("SECOND_FIELD", "Assessment year", _
Autodesk.Gis.Map.Constants.DataType.Integer, 1)
def2.SetDefaultValue(0)
Get a reference to the ODTables property for the drawing, and add the field defintions to create a new table.
Dim tables As ObjectData.Tables
tables = mapApp.ActiveProject.ODTables
tables.Add("NewTable", fieldDefs, "Description", True)
Get a reference to the table using Tables.Item(). This expects a string parameter.
Dim table As ObjectData.Table
table = tables("NewTable")