Introduction

AutoCAD Map 3D .NET API

 
Introduction
 
 
 

Object data provides a way of attaching additional information to drawing objects. It is more powerful and flexible than AutoCAD block attributes because object data can be attached to any object in a drawing.

NoteObject data can only be attached to drawing objects. FDO feature sources have a different way to handle feature properties.

The classes for handling object data are mostly within the ObjectData namespace. Code in this chapter assumes the following:

Imports Autodesk.Gis.Map.ObjectData

Tables

Internally, object data is stored in tables. Each drawing has its own set of tables, available from the ProjectModel.ODTables property. This returns an object of type ObjectData.Tables.

For example, if mapApp is the Map application, the following will get the object data tables for the active drawing:

Dim activeProject As Project.ProjectModel = mapApp.ActiveProject
Dim tableList As ObjectData.Tables = activeProject.ODTables

ObjectData.Tables.GetTableNames() returns a list of the table names that have been defined for the drawing.

To get a single table from the set of tables, use the ObjectData.Tables.Item property. Note that this requires a table name as a parameter, not a table number. For example:

Dim table As ObjectData.Table = tableList.Item("table1")

or

Dim table As ObjectData.Table = tableList("table1")

Use Tables.IsTableDefined() to see if a table name exists. An attempt to get a table that does not exist throws an exception.

Field Definitions

Columns in a table are defined by ObjectData.FieldDefinition objects, which describe the data type and default value. The data types are defined in the Constants.DataType enum:

  • UnknownType
  • Integer
  • Real
  • Character
  • Point

Records

Each row in the table is of type ObjectData.Record. Every record in the table is associated with a drawing object.

The Item property of an ObjectData.Record contains the values for the record, one for each field definition in the table. Each item is of type Utilities.MapValue, which is a general-purpose class for storing data.