ObjectARX C++ Developer's Guide
ObjectARX C++ Developer's Guide
ObjectARX C++ Developer's Guide
ObjectARX C++
Developer's Guide
April 2009
© 2009 Autodesk, Inc. All Rights Reserved. Except as otherwise permitted by Autodesk, Inc., this publication, or parts thereof, may not be
reproduced in any form, by any method, for any purpose.
Certain materials included in this publication are reprinted with the permission of the copyright holder.
Trademarks
The following are registered trademarks or trademarks of Autodesk, Inc., in the USA and other countries: 3DEC (design/logo), 3December,
3December.com, 3ds Max, ADI, Alias, Alias (swirl design/logo), AliasStudio, Alias|Wavefront (design/logo), ATC, AUGI, AutoCAD, AutoCAD
Learning Assistance, AutoCAD LT, AutoCAD Simulator, AutoCAD SQL Extension, AutoCAD SQL Interface, Autodesk, Autodesk Envision, Autodesk
Insight, Autodesk Intent, Autodesk Inventor, Autodesk Map, Autodesk MapGuide, Autodesk Streamline, AutoLISP, AutoSnap, AutoSketch,
AutoTrack, Backdraft, Built with ObjectARX (logo), Burn, Buzzsaw, CAiCE, Can You Imagine, Character Studio, Cinestream, Civil 3D, Cleaner,
Cleaner Central, ClearScale, Colour Warper, Combustion, Communication Specification, Constructware, Content Explorer, Create>what's>Next>
(design/logo), Dancing Baby (image), DesignCenter, Design Doctor, Designer's Toolkit, DesignKids, DesignProf, DesignServer, DesignStudio,
Design|Studio (design/logo), Design Web Format, Discreet, DWF, DWG, DWG (logo), DWG Extreme, DWG TrueConvert, DWG TrueView, DXF,
Ecotect, Exposure, Extending the Design Team, Face Robot, FBX, Filmbox, Fire, Flame, Flint, FMDesktop, Freewheel, Frost, GDX Driver, Gmax,
Green Building Studio, Heads-up Design, Heidi, HumanIK, IDEA Server, i-drop, ImageModeler, iMOUT, Incinerator, Inferno, Inventor, Inventor
LT, Kaydara, Kaydara (design/logo), Kynapse, Kynogon, LandXplorer, LocationLogic, Lustre, Matchmover, Maya, Mechanical Desktop, Moonbox,
MotionBuilder, Movimento, Mudbox, NavisWorks, ObjectARX, ObjectDBX, Open Reality, Opticore, Opticore Opus, PolarSnap, PortfolioWall,
Powered with Autodesk Technology, Productstream, ProjectPoint, ProMaterials, RasterDWG, Reactor, RealDWG, Real-time Roto, REALVIZ,
Recognize, Render Queue, Retimer,Reveal, Revit, Showcase, ShowMotion, SketchBook, Smoke, Softimage, Softimage|XSI (design/logo),
SteeringWheels, Stitcher, Stone, StudioTools, Topobase, Toxik, TrustedDWG, ViewCube, Visual, Visual Construction, Visual Drainage, Visual
Landscape, Visual Survey, Visual Toolbox, Visual LISP, Voice Reality, Volo, Vtour, Wire, Wiretap, WiretapCentral, XSI, and XSI (design/logo).
The following are registered trademarks or trademarks of Autodesk Canada Co. in the USA and/or Canada and other countries:
Backburner,Multi-Master Editing, River, and Sparks.
The following are registered trademarks or trademarks of MoldflowCorp. in the USA and/or other countries: Moldflow, MPA, MPA
(design/logo),Moldflow Plastics Advisers, MPI, MPI (design/logo), Moldflow Plastics Insight,MPX, MPX (design/logo), Moldflow Plastics Xpert.
All other brand names, product names or trademarks belong to their respective holders.
Disclaimer
THIS PUBLICATION AND THE INFORMATION CONTAINED HEREIN IS MADE AVAILABLE BY AUTODESK, INC. "AS IS." AUTODESK, INC. DISCLAIMS
ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE REGARDING THESE MATERIALS.
Published by:
Autodesk, Inc.
111 Mclnnis Parkway
San Rafael, CA 94903, USA
Contents
Chapter 4 Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Queries Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
iii
Chapter 7 Property Alteration Sample . . . . . . . . . . . . . . . . . . . . 23
Property Alteration Sample . . . . . . . . . . . . . . . . . . . . . . . . 23
Chapter 17 Import-Export . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Import-Export Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
iv | Contents
Subclassing Custom Reactors . . . . . . . . . . . . . . . . . . . . . . . 88
Exporting to an Oracle Spatial Database . . . . . . . . . . . . . . . . . 89
Importing from an Oracle Spatial Database . . . . . . . . . . . . . . . 92
Getting Corresponding IDs . . . . . . . . . . . . . . . . . . . . . . . . 94
Filtering Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Contents | v
vi
Before You Begin
1
AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to
automate and extend AutoCAD Map 3D.
AutoCAD Map 3D ObjectARX extends AutoCAD ObjectARX into the AutoCAD Map 3D
domain.
The ObjectARX and ObjectARX .NET APIs each cover most of AutoCAD Map 3D functionality.
But they don't cover Resource Service, Feature Service, or Mapping Service. These areas are
covered by the Geospatial Platform API, which is exposed as .NET only.
Sources of Information
To develop applications using AutoCAD Map 3D ObjectARX, you should be
familiar with AutoCAD ObjectARX and also the AutoCAD Map 3D and AutoCAD
applications.
1
Compatability of SDKs
The AutoCAD Map 3D SDK must be installed in an existing AutoCAD SDK
installation, and the AutoCAD Map 3D SDK and AutoCAD SDK versions must
be compatible with each other and with the version of AutoCAD Map 3D that
you are extending. For example, the AutoCAD Map 3D 2008 SDK must be
installed into an existing AutoCAD 2008 SDK installation, and you need both
to build ObjectARX applications for AutoCAD Map 3D 2008.
Typographic Conventions
Text element Description
NOTE Note All file names and directory paths in AutoCAD Map 3D are case
sensitive.
Attached Drawings
A drawing set is a tree of attached drawings. Any of the attached drawings can
have other drawings attached to them. The drawings that are not directly
attached to the root of the drawing set (at level 0 of the tree) are called nested
drawings.
You can use AcMapDrawingSet functions to edit and manipulate only drawings
that are directly attached to the drawing set at the root level (level 0) of the
drawing set. To access and edit drawings at deeper levels, use the functions of
the AcMapAttachedDrawing class.
A single drawing can be directly attached to the drawing set only once. However,
a single drawing can have multiple entries in the drawing set at nested levels 1
and deeper.
You can designate an attached drawing as active or inactive. When a query is
executed in the project, only the active drawings are considered. When you
work with object data in a project, open drawings instead of attaching them.
3
activation, or deactivation. Whenever the drawing set is modified, an
appropriate function of the reactor object is called before termination of the
zero level Map transaction.
2 Clone the drawing objects that you wish to save using one of the
AcMapAttachedDrawing class's functions.
5
void editDSet()
{
AcMapSession *mapApi;
AcMapProject *pProj;
AcMapDrawingSet *pDSet;
char res[32];
do {
mapApi = AcMapGetSession();
if (mapApi == NULL)
{
acutPrintf ("\nCan't connect MAP") ;
break ;
}
if (mapApi->GetProject(pProj) == Adesk::kFalse)
{
break ;
}
if (pProj->GetDrawingSet(pDSet) == Adesk::kFalse)
{
acutPrintf ("\nCan't get drawing set") ;
break ;
}
do {
// Setup
printDSet(pDSet) ;
*res = EOS ;
acedInitGet(
0,
"eXit aTtach Detach Activate deaCtivate Settings
gettaBle aLiases View Preview Report Query Zoom") ;
if (acedGetKword(
"\naTtach/Detach/Activate/deaCtivate/
Settings/gettaBle/aLiases/View/Preview/Report/
Query/Zoom/<eXit>: ",
res
) == RTNORM)
{
if (*res == EOS || !(strcmp(res, "eXit")))
{
break ;
}
// Attach a drawing
else if (!strcmp(res, "aTtach"))
Queries Detail
After a query has been defined, it can be saved externally and subsequently
loaded into an application, where it can be executed or modified.
The building blocks for creating a query definition are query conditions and
query branches.
Query Conditions
The criteria that the query uses to select objects are expressed in query
conditions. There are four types of query conditions.
Description
11
Description
specified by the WHERE clause of a SQL
query.
Location Boundaries
There are several types of location boundaries. They are all represented by
descendents of the AcMapLocationBoundary class, as illustrated in the
following diagram.
For more information about query condition types, refer to AutoCAD Map
3D Help. On the Contents tab, click Using AutoCAD Map 3D > Queries >
Defining Queries.
Query Branches
Query branches are trees composed of query conditions, possibly subordinate
query branches, and join operators, which connect the components.
The following diagram illustrates the structure of a simple query branch, in
which a, b, and c are query conditions and AND and OR are join operators.
It expresses the query, a AND b or c.
12 | Chapter 4 Queries
Both query branches and query conditions inherit from the same base class,
as shown in the following diagram.
To build a query
1 Create one or more query conditions (also called query units or operands).
Queries Detail | 13
To execute a query
1 You may want to set the mode, enable or disable property alteration, or
create a report template for the query.
14 | Chapter 4 Queries
Query Sample
5
The following sample demonstrates query operations.
15
Query Sample Code
Property Alteration
You associate a property alteration definition with the query that it affects using
the AcMapQuery::GetPropertyAlteration function. You create a property
alteration and add it to the definition, with the
AcMapPropertyAlterationDefinition::AddAlteration function.
The classes used to create and manipulate property alteration for a query are
AcMapPropertyAlterationDefinition AcMapPropertyAlteration
AcMapTextAlteration AcMapHatchAlteration
The last two classes, which are subclassed from AcMapPropertyAlteration, are
specialized property alterations for adding text labels and hatch patterns to
queried objects.
You can alter properties conditionally, depending on existing values of the
property to be altered or of some other property. To do so, you will also need
to use the following classes:
AcMapRangeLibrary AcMapRangeTable AcMapRangeLine
Property Types
A property alteration's type identifies the property that it alters. The properties
that can be altered are enumerated in AcMap::EAlterationType. When you create
a property alteration, you set its type by assigning it one of these enumerators.
19
Note that two of these enumerators, AcMap::kAlterationTextEntity and
AcMap::kAlterationHatch, create the specialized property alteration objects
AcMapTextAlteration and AcMapHatchAlteration, which are subclassed from
AcMapPropertyAlteration. The remaining enumerators simply identify the
different kinds of AcMapPropertyAlteration objects, the simple property
alterations.
AcMapTextAlteration objects in a property alteration definition create text
objects when the query exceutes, which serve as text labels for queried objects.
AcMapHatchAlteration objects create hatch objects, which apply hatch patterns
to closed or closeable queried objects.
The value that the property acquires when the query is run is indicated by
the property alteration's value expression, which you set with the
AcMapPropertyAlteration::SetExpression function. For example, if the property
alteration's type is AcMap::kAlterationColor, you might set its expression to
"Red". If the property alteration's type is AcMap::kAlterationTextEntity, the
property alteration's value expression is the text for the label. If the type is
AcMap::kAlterationHatch, the value expression is a pattern name.
4 Repeat steps 2 and 3 for every property alteration that you want to be
executed by the query.
Property Alteration | 21
22
Property Alteration Sample
7
This example shows how to create range lines and alterations.
23
////////////////////////////////////////
// MAIN LOOP
//
// Clears the current query and calls
// DefineRangeLines(), TextAlt(), and
// HatchAlt().
//
////////////////////////////////////////
void doPropAlts()
{
AcMapSession *mapSession = NULL;
mapSession = AcMapGetSession();
if (mapSession)
{
AcMapProject *pProj;
if (mapSession->GetProject(pProj) == Adesk::kTrue)
{
// Get the current Query
AcMapQuery *pCurrentQuery = NULL;
if (pProj->CreateQuery(
pCurrentQuery,
Adesk::kTrue
) == AcMap::kOk)
{
// Before we start, clear the current query
pCurrentQuery->Clear(Adesk::kTrue);
// clean up
delete pCurrentQuery;
}
}
}
// make the calls
DefineRangeLines()
TextAlt()
HatchAlt()
}
////////////////////////////////////
// DefineRangeLines()
//
// Creates two range tables and
// adds them to the range library
//
////////////////////////////////////
■ Subclass each custom object class from the appropriate ARX parent class, as
detailed below.
■ Ensure that each custom object instance in a drawing is added to the Model
Space section of the drawing's Block table.
33
Queryable Property Class to Derive From Methods to Overload
35
36
Data Sources
10
The AutoCAD Map 3D data-sources feature links information from an external database to
objects in a drawing.
Data Sources on page 37
Other Information Sources
Data Sources Samples on page 38Data Sources Class on page 38
Data Sources
The AcMapDataSources class provides the following data-sources functions:
■ Constructor/destructor - AcMapDataSources()/~AcMapDataSources()
For data-sources source-code samples, see Data Sources Samples on page 38.
37
Other Information Sources
■ For more information about data sources in AutoCAD Map 3D, choose Help > Autodesk
Map Help > Contents tab (or press F1), and then navigate to Using AutoCAD Map 3D
(by feature) > External Databases > Attaching and Configuring Data Sources.
■ For a data-sources tutorial in AutoCAD Map 3D, choose Help > Tutorials > Contents tab,
and then choose "Working with External Databases".
39
40
Object Data Samples
12
Creating an Object Data Table
The following sample creates an object data table called Zones with two columns,
Residential and Commercial.
2 Create variables for the session, project, object data container, table, and
columns. For example, create variables for a table with two columns.
AcMapSession *mapApi;
AcMapProject *pProj;
AcMapODContainer *pODCont;
AcMapODTableDefinition *pTabDef = NULL;
AcMapODColumnDefinition *pColDef1 = NULL;
AcMapODColumnDefinition *pColDef2 = NULL;
3 Create an AutoCAD Map 3D session and get the top level objects.
mapApi = AcMapGetSession();
mapApi->GetProject(pProj);
pProj->GetODContainer(pODCont);
41
4 Allocate memory for table and column objects by calling the table and
column constructors with the new operator.
pTabDef = new AcMapODTableDefinition();
pColDef1 = new AcMapODColumnDefinition();
pColDef2 = new AcMapODColumnDefinition();
5 For each of the columns, set the column name and description and the
type of data the column stores. Set the default value for the data.
pColDef1->SetName("Residential");
pColDef1->SetDescription("Residential R1-R3");
pColDef1->SetType(AcMap::kCharacter);
pColDef1->SetDefaultValue("R1");
pColDef2 = new AcMapODColumnDefinition();
pColDef2->SetName("Commercial");
pColDef2->SetDescription("Commercial C1-C3");
pColDef2->SetType(AcMap::kCharacter);
pColDef2->SetDefaultValue("C1");
7 Create the object data table. For example, create a table called Zones to
store XData using the following code:
pODCont->CreateODTable("Zones", *pTabDef, "Zoning of King
City",
Adesk::kTrue);
8 Release the memory you allocated for the table and columns in step 4
using the delete operator.
if (pColDef2) delete pColDef2;
if (pColDef1) delete pColDef1;
if (pTabDef) delete pTabDef;
2 Declare variables.
ads_name ss, ename;
long sslen, sscur;
AcDbObjectId eId;
AcMapSession *mapApi = NULL;
AcMapProject *pProj = NULL;
AcMapODContainer *pODCont = NULL;
AcMapODTable *pODTable = NULL;
3 Create an AutoCAD Map 3D session and get the top level objects.
mapApi = AcMapGetSession();
mapApi->GetProject(pProj);
pProj->GetODContainer(pODCont);
5 Use ADS functions to prompt user to select the objects to which to attach
the data, and process the selections.
acutPrintf("\nAttach data to which object(s)?");
if (acedSSGet(NULL, NULL, NULL, NULL, ss) != RTNORM) {
acutPrintf("\nNo objects selected.\n");
acedSSFree(ss);
return;
}
7 Loop through the objects selected in step 5, getting the entity name of
the next object, and converting it to an object ID, which you pass to
AcMapODTable::AddRecord. Within the for loop, you create the
AcMapODTableRecord using the new operator, thereby allocating memory
To traverse records
2 Declare variables.
int retCode = FALSE;
ads_name ename;
ads_point spt;
AcDbObjectId eId;
int recQuantity = 0;
AcMapSession *mapApi = NULL;
3 Create an AutoCAD Map 3D session and get the top level objects.
mapApi = AcMapGetSession();
mapApi->GetProject(pProj);
pProj->GetODContainer(pODCont);
4 Use ADS functions to prompt user to select an object, and convert the
entity name of the selected object to an object ID for initializing the
iterator in the next step.
retCode = acedEntSel(NULL, ename, spt);
if (retCode != RTNORM) {
acutPrintf("\nNo object selected.\n");
return;}
acdbGetObjectId(eId, ename);
6 Use the record iterator to count records attached to the object. Print the
results.
recQuantity = pIter->CountRecords();
acutPrintf("\nObject has %d records attached.", recQuantity);
2 Define a constant for input of the record values and declare variables.
#define USR_STRG_LENGTH 133
int retCode = FALSE;
ads_name ename;
ads_point spt;
char zoneCode [USR_STRG_LENGTH] = "";
char approveCode [USR_STRG_LENGTH] = "";
AcMapSession *mapApi = NULL;
AcMapProject *pProj = NULL;
AcMapODContainer *pODCont = NULL;
AcMapODRecordIterator *pIter = NULL;
AcDbObjectId eId;
AcMapODTableRecord record;
3 Create an AutoCAD Map 3D session and get the top level objects.
mapApi = AcMapGetSession();
mapApi->GetProject(pProj);
pProj->GetODContainer(pODCont);
4 Use ADS functions to prompt user to select an object, and convert the
entity name of the selected object to an object ID for initializing the
iterator in the next step.
retCode = acedEntSel(NULL, ename, spt);
if (retCode != RTNORM) {
acutPrintf("\nNo object selected.\n");
return;}
5 Get a record iterator and initialize it for writing. Using the iterator in a
for loop, traverse the records of the object selected in step 4, getting the
table associated with each record.
pODCont->GetObjectODRecordIterator (pIter);
pIter->Init (eId, AcMap::kOpenForWrite, Adesk::kFalse);
for (; pIter->IsDone() == Adesk::kFalse; pIter->Next())
{
pIter->GetRecord (record);
pODCont->GetODTable (pTable, record.ODTableName());
acutPrintf("\n*** OD Table %s.", record.ODTableName());
6 Loop through the columns of each record, and print the name of the
column, which in this example is either Code or Approved By.
for (int i = 0; i < record.Count(); i++)
{
AcMapODTableDefinition tableDef = pTable->Definition();
AcMapODColumnDefinition Column;
tableDef.GetColumn(Column, i);
acutPrintf("\n%-15s", Column.Name());
7 Print the value at the column of the record and get a pointer, colname,
to the column.
AcMapValue &val = record.Value(i);
acutPrintf(" %s", ((const char *)val));
colname = Column.Name();
8 Create an AcMapValue variable and assign the value entered by the user
to it. Then, assign the AcMapValue variable to the value of the record
using the AcMapODTableRecord::Value function. Update the record using
the record iterator.
if(!strcmp(colname, "Code")){
acedGetString(TRUE,"\nNew zoning code:", zoneCode);
AcMapValue v = zoneCode;
record.Value(i) = v;
pIter->UpdateRecord(record);
}
9 Using the same paradigm as step 9, get and update the record's Approved
by column.
if(!strcmp(colname, "Approved")){
acedGetString(TRUE,"\nApproved by:", approveCode);
10 End the for loop started in step 7 and delete the pointer to the table
created with AcMapODContainer::GetODTable. End the for loop started
in step 6 and delete the iterator created in step 5.
}//end for
if (pTable) delete pTable;
} //end for
if (pIter) delete pIter;
Coordinate-Systems Functions
The following coordinate-systems functions are available:
■ For more information about coordinate systems in AutoCAD Map 3D, choose
Help > Autodesk Map Help > Contents tab (or press F1), and then navigate
to Using AutoCAD Map 3D (by feature) > Coordinate Systems.
49
■ For a coordinate-systems tutorial in AutoCAD Map 3D, choose Help >
Tutorials > Contents tab, and then choose "Working with Coordinate
Systems".
Converting Coordinates
Any Cartesian coordinate pair you select in a geo-referenced coordinate system
corresponds to a point on the surface of the earth. This fact defines a relation
between the coordinate pairs in one coordinate system and the coordinate pairs
in any other, so long as the point in question actually exists in both systems.
In other words, so long as the coordinate systems have a region of intersection,
and the point in question is in it.
51
you don't know the specific coordinate system code, click Select Coordinate
System. In the Select Global Coordinate System dialog box, which is located
under the Map ->Tools->Assign Global Coordinate System menu option. Select
a category, and then select from a list of available coordinate systems. Click
Properties to view the Code value of the selected coordinate system.
Converting Coordinates | 53
54
Feature Classification
15
Use AutoCAD Map 3D's feature-classification feature to create standard objects in drawings.
55
Creating and Managing Schemas
Before you can Creating and Managing Feature Class Definitions on page 57,
you must create a schema and attach it to the current drawing by using
AcMapClassificationManager functions. However, before you create a new
feature-definition file with CreateFeatureDefinitionFile(), use
CanCurrentUserAlterSchema() to check whether the current user has sufficient
privileges to create or change a schema. (Even though you don't check this
first, CreateFeatureDefinitionFile() will catch an insufficient-privileges error.)
Alternatively, rather than creating a new schema, use the currently attached
schema, indicated by GetFeatureDefinitionFileAttached(), or attach an existing
schema with AttachFeatureDefinitionFile(). You can detach a schema explicitly
with DetachCurrentFeatureDefinitionFile().
After creating or modifying a feature class definition in a schema, save the file
withSaveCurrentFeatureDefinitionFile()or save a copy
withSaveCurrentFeatureDefinitionFileAs(). You also can refresh the current
schema withReloadCurrentFeatureDefinitionFile(), but doing so is risky because
it might reload outdated data, depending on the user's actions.
For feature-classification source-code samples, seeFeature Classification Samples
on page 63.
Classifying Entities
After you create feature class definitions, you can use them to classify the
entities in the current drawing by using AcMapClassificationManager functions.
Use any of the following methods to check entities:
■ Use GetUndefinedEntities() to list entities that are classified but whose feature
class definitions are not in the attached feature-definition file.
■ Name - GetName()/SetName()
■ Description -GetDescription()/SetDescription()
■ Icon -GetIconName()/SetIconName()
■ Visibility -IsVisibleInWorkspace()/SetVisibleInWorkspace()
Use the following functions to determine where a specific feature class exists
in the feature-class
■ Name - GetName()
■ Type - GetType()
■ Range -GetRange()/SetRange()/IsInRange()
■ Visibility -IsVisible()/SetVisible()
■ Read-only -IsReadOnly()/SetReadOnly()
Handling Errors
Many functions in the various feature-classification classes return an
AcMapObjClass::EErrCode error code. When a particular function returns an
error code, read that function's documentation for function-specific error
conditions rather than relying on only the generic error descriptions in the
AcMapObjClass::EErrCode documentation.
■ Constructor/destructor - AcDbObjectFilter()/~AcDbObjectFilter()
Basic Filters
The AcDbBasicFilter class (derived from The AcDbObjectFilter) filters objects in
the current drawing based on layer, feature-class, and block criteria, and provides
the following functions:
■ Layer filters:
65
■ Set layers - SetLayers() (two forms)
■ Feature-class filters:
■ Block filters:
■ Constructor/destructor - AcDbObjectFilterGroup()/~AcDbObjectFilterGroup()
■ For more information about object filters in AutoCAD Map 3D, choose
Help > Autodesk Map Help > Index tab, and then type the keywords filters
and queries to display the related topics.
Import-Export Detail
By importing a map, you can combine data from other mapping or GIS programs
by importing the data into AutoCAD Map 3D. You can import the map objects
themselves, and the data and display options associated with them. In addition,
you can specify an import area to determine which area of the map will be
imported, assign incoming objects to existing feature classes, and automatically
perform a coordinate conversion on the objects as they are imported.
By exporting a map, you can export data to an external file format. You can
export the map objects themselves, and the data associated with them, and
specify that AutoCAD Map 3D performs a coordinate conversion on the objects
automatically as they are exported.
Use profiles to save your import and export settings in a profile to automate
the process of importing and exporting files. You can save and load import
profile files (.ipf) or export profile files (.epf).
The following file formats are supported for both import and export, unless
otherwise indicated:
69
■ MapInfo MIF/MID
■ MapInfo TAB
Importing Maps
To import an file to an AutoCAD Map 3D drawing, perform the following
steps, as shown in the sample code that follows:
2 Initialize the importer with Init(). (You must call Init() before you call
any other AcMapIEImporter functions.)
Init() requires an AcMapIEFormat name that specifies the format of the
incoming file.
70 | Chapter 17 Import-Export
AcMapIE::ErrCode errCode;
// Retrieve the AutoCAD Map 3D importer object.
AcMapIEImporter* pImporter = AcMapImporter();
// Initialize the importer.
char* pszFormat = "MIF"; // Name of an AcMapIEFormat.
char* pszImpFileName = "C:\\temp\\my_import_file.mif";
errCode = pImporter->Init(pszFormat, pszImpFileName);
if (errCode != AcMapIE::kErr_OK)
{
// Handle the error.
}
// Get an iterator over the layers in the imported file.
AcMapIEInputLayerIterator* pInputLayers;
errCode = pImporter->InputLayerIterator(pInputLayers);
if (errCode != AcMapIE::kErr_OK)
{
// Handle the error.
}
// Iterate over each layer.
for (pInputLayers->Rewind(); !pInputLayers->Done(); pInputLayers-
>Step())
{
AcMapIEInputLayer* pLayer = NULL;
if(pInputLayers->Get(pLayer) == false)
{
// Handle the error.
}
// Import attribute data from the import file to the
// new object-data table in the Autocad Map drawing.
// Insert code to set the table type and table name
// with AcMapIEInputLayer::SetDataMapping()
// and set the feature class name
// with AcMapIEInputLayer::SetFeatureClassName().
// Set column mappings.
AcMapIEColumnIterator* pColumns = pLayer->ColumnIterator();
if(pColumns)
{
for (pColumns->Rewind(); !pColumns->Done(); pColumns->Step())
{
// Insert code to set column data mappings
// with AcMapIEColumn::SetColumnDataMapping()
// and set column feature-class mappings
// with AcMapIEColumn::SetColumnClassMapping().
Import-Export Detail | 71
}
delete pColumns;
}
delete pLayer;
}
delete pInputLayers;
// Perform the import and get the results.
AcMapIE::CImportResults results;
bool bUseProgressDialog = false;
errCode = pImporter->Import(results, bUseProgressDialog);
if(errCode != AcMapIE::kErr_OK)
{
// Handle the error.
}
// Process or log the import results, if desired.
72 | Chapter 17 Import-Export
On each layer, you can set individual mappings from each incoming column
to a target column in AutoCAD Map 3D. AcMapIEInputLayer::ColumnIterator()
retrieves an iterator over a layer's columns; each column is an AcMapIEColumn
instance, named ColumnName(). You can define two types of column mappings,
provided that you already have set the column's data table and feature class
with AcMapIEInputLayer::SetDataMapping() and
AcMapIEInputLayer::SetFeatureClassName():
You also can use the following AcMapIEImporter functions to set and retrieve
high-level import options:
■ Location-window filter -
LocationWindowAndOptions()/SetLocationWindowAndOptions(). See also
AcMapIE::LocationOption enum.
Exporting Maps
To export an AutoCAD Map 3D drawing, perform the following steps, as
shown in the sample code that follows:
2 Initialize the exporter with Init(). (You must call Init() before you call any
other AcMapIEExporter functions.)
Init() requires an AcMapIEFormat name that specifies the target file format.
You can use FormatName() to retrieve the format name at any time after
initialization.
Import-Export Detail | 73
3 Optionally, add reactors to the exporter.
74 | Chapter 17 Import-Export
can set storage options, driver options, data mappings, and other options. Use
the following AcMapIEExporter functions to set and retrieve export options:
■ Polygon topology -
ExportFromPolygonTopology()/SetExportFromPolygonTopology()
Import-Export Detail | 75
Export reactor function Invoked
76 | Chapter 17 Import-Export
// Derive a custom class from AcMapIEExportReactor.
class AcMapIEMyExportReactor : public AcMapIEExportReactor
{
// Override virtual functions for the desired export events.
} ;
// Create an instance of the custom reactor.
AcMapIEMyExportReactor* pMyReactor = new AcMapIEMyExportReactor;
// Add the custom reactor.
AcMapIEExporter().AddReactor(pMyReactor);
// Insert export reactor code here.
// Remove the reactor and delete it.
AcMapIEExporter().RemoveReactor(pMyReactor);
delete pMyReactor;
Using Iterators
The following table lists the iterator classes, which provide iterators over
collections of objects that import-export functions return or take. The
AcMapIEExpressionTargetIteratorand AcMapIENameValueIteratorclasses allow
you to modify the iterator's underlying collection by adding, updating, and
deleting elements, whereas the other classes iterate over fixed collections. The
global
functionsAcMapExportFormatIterator()andAcMapImportFormatIterator()return
the export-format and import-format iterators, respectively.
Handling Errors
Many functions in the various import-export classes return an AcMapIE::ErrCode
error code. When a particular function returns an error code, read that
function's documentation for function-specific error conditions rather than
Import-Export Detail | 77
relying on only the generic error descriptions in the AcMapIE::ErrCode
documentation.
■ For an import-export tutorial in AutoCAD Map 3D, choose Help > Tutorials
> Contents tab, and then choose "Importing and Exporting Data".
Import-Export Samples
To view code samples of import-export functions, open the Samples folder in
your AutoCAD Map 3D ObjectARX installation and navigate to Map
Samples\ImportExport.
78 | Chapter 17 Import-Export
Oracle Spatial Data
18
This topic describes the latest implementation of the Oracle Spatial API.
79
Managing the connection
Before you can do anything else, you must get the AcMapOSEConnection
object.
So long as AutoCAD Map 3D is running, there is always an
AcMapOSEConnection object, even if no connection is currently in effect.
The object is instantiated automatically when an AutoCAD Map 3D session
opens, and is destroyed automatically when the session closes.
Because the AcMapOSEConnection object is unique within a session, there
can never be more than one connection in effect at a time. To connect,
disconnect, or change the current connection, you modify this unique object.
You can modify it (or assess its state) either through the the UI or the API. It's
the same object either way.
AcMapOSEConnection class
AcMapOSEGetConnection global function
Connecting to an Oracle Spatial Database on page 85
Managing reactors
In addition to functions for modifying or assessing its state, the
AcMapOSEConnection object has functions for managing reactors. For
example, to monitor and react to connection events, subclass a custom reactor
from AcMapOSEConnectionReactor, and then add an instance of it to your
application using AcMapOSEConnection::AddConnectionReactor(). Similarly,
you can create and add reactors for import and export events.
AcMapOSEConnection class
AcMapOSEConnectionReactor class
AcMapOSEExportReactor class
AcMapOSEImportReactor class
Connecting to an Oracle Spatial Database on page 85
Exporting data
To add new records to the Oracle database, or to update records that were
imported and then edited by adding, changing, or deleting data, use an
AcMapOSEExport object. To set export options and specify which features
will be exported, use AcMapOSEExport::Init().
Note that an AcMapOSEExport object has two functions for exporting.
ExportObjects() exports objects listed in an AcDbObjectIdArray.
■ The current import query, as defined in the Import dialog box in the user
interface.
To see this dialog, use the MAPOSEREAD command.
■ An import query loaded from the Oracle database after saving one there
previously.
After initializing the AcMapOSEQuery object, you can convert its query to
SQL format for viewing purposes.
To monitor and react to import events, use a custom subclass of
AcMapOSEImportReactor.
AcMapOSEQuery class
AcMapOSEImport class
AcMapOSEImportReactor class
Filtering objects
To filter new objects from a set of drawing objects, use
AcMapOSEProject::FilterNewObjects(). In addition, you can constrain the
result by feature or edit-set status (in or out).
Error processing
When an AutoCAD Map 3D operation fails, the error message and error code
are pushed to the error stack (AcMapErrorStack). In the event of an error,
check the stack to discover what went wrong and take appropriate action.
■ User Interface Help for the Polygon and Advanced Oracle Extension to AutoCAD
Map 3D— In the Autodesk Map application, click the question mark icon
in the Polygon And Advanced Oracle Extension toolbar.
Code samples
To view code samples, click links below.
Connecting to an Oracle Spatial Database on page 85
Exporting to an Oracle Spatial Database on page 89
Importing from an Oracle Spatial Database on page 92
Subclassing Custom Reactors on page 88
Getting Corresponding IDs on page 94
Filtering Objects on page 98
The following topics describe sample ObjectARX projects. The project folders
are under Map Samples\Oracle Spatial in your AutoCAD Map 3D ObjectARX
installation.
Storing Block Attribute Positions in an Oracle Spatial Database on page 106
Storing Block Definitions in an Oracle Spatial Database on page 105
Importing From an Oracle Spatial Database on page 103
Classes
To view Oracle Spatial data classes, click links below.
AcMapOSEConnection
AcMapOSEConnectionReactor
AcMapOSEExport
AcMapOSEExportReactor
AcMapOSEImport
AcMapOSEImportReactor
AcMapOSEObject
AcMapOSEProject
AcMapOSEQuery
85
#include "StdAfx.h"
#include "StdArx.h"
#include "AdMapOracleConnection.h"
#include "MyMapOracleReactors.h" // Custom reactors
BOOL ConnectToOracle()
{
// Get connection pointer
AcMapOSEConnection *pConnection = AcMapOSEGetConnection();
// Initialize reactors
MyConnectionReactor *pConnectReactor = new MyConnectionReact
or();
MyExportReactor *pExportReactor = new MyExportReactor();
MyImportReactor *pImportReactor = new MyImportReactor();
// Add reactors to connection object
pConnection->AddConnectionReactor(pConnectReactor);
pConnection->AddExportReactor(pExportReactor);
pConnection->AddImportReactor(pImportReactor);
// Make the connection
BOOL bConnect = FALSE;
if(!pConnection->IsConnected())
{
bConnect = pConnection->Connect("Scott", "TestDB", "Scott",
"Tiger", false);
}
else
{
acutPrintf("Already connected to Oracle!");
return FALSE;
}
// Check for valid connection using various diagnostic func
tions
// Check if schema is valid()
if(pConnection->IsSchemaValid())
{
acutPrintf("\nSchema is valid for this connection\n");
}
else
{
acutPrintf("\nSchema is not valid\n");
}
// Get the latest state of the Oracle database if it has been
NOTE The sample assumes an open project drawing containing some objects.
It also assumes that the connection object is actually connected to a database.
Click "Connecting to an Oracle Database" for sample code.
NOTE The sample assumes that there is an open project drawing, and that an
import query has been defined already through the Import dialog box in the UI
(use the MAPOSEREAD command). It also assumes that the connection object is
actually connected to a database. Click "Connecting to an Oracle Database" for
sample code.
NOTE The sample assumes an open project drawing containing imported entities.
It also assumes that the connection object is actually connected to a database.
Click "Connecting to an Oracle Database" for sample code.
Filtering Objects
The following code sample illustrates filtering queried and new drawing objects,
and adding and removing objects from the EditSet.
Filtering objects on page 82
Code samples on page 83
Filtering Objects | 99
acutPrintf("\n Filter array = %d\n",ar
rFilteredOut.length());
} else {
acutPrintf("\nFilterQueriedObjects() returned false\n");
}
// Filter new objects
// Filter these features
vFeatureNames.push_back("Feature1");
vFeatureNames.push_back("Feature2");
// Empty input array of objectIds means filter all objects
// in the drawing database
AcDbObjectIdArray arrInput, arrNew, arrFilteredOut;
if(pProject->FilterNewObjects(
vFeatureNames,
arrInput,
arrNew,
arrFilteredOut,
AcMapOSEProject::kInEditSet | AcMapOSEProject::kNotInEditSet))
{
acutPrintf("\n Input array = %d\n",arrInput.length());
acutPrintf("\n New array = %d\n",arrErased.length());
acutPrintf("\n Filter array = %d\n",arrFilteredOut.length());
} else {
acutPrintf("\nFilterNewObjects() returned false\n");
}
// Add objects to EditSet
// Populate arrAcadIds with drawing objects by manually
// selecting or iterating through drawing database;
// arrFilteredOut reports objects that could not be
// added to the EditSet
AcDbObjectIdArray arrAcadIds, arrFilteredOut;
// ... (add code to populate arrAcadIds)
if(pProject->AddToEditSet(arrAcadIds, arrFilteredOut))
{
acutPrintf("\nObjects added to EditSet\n");
}
else
{
acutPrintf("\nError adding objects to EditSet\n");
}
// Remove objects from EditSet
// Populate arrAcadIds with drawing objects by manually
// selecting or iterating through drawing database;
Commands Implemented
The project creates an rx module which exposes the following commands.
103
Import dialog box
The ORAAPIIMPORT command opens the Import dialog box, which includes
the following elements, among others.
Table aliases
To compose a condition for a given feature, you have to specify which table
to use if the feature has more than one, and you have to refer to this table by
its alias. If there is only one table, its alias is "Table0" and specifying it is
optional. The following condition uses a table alias.
Select *
From RIVERS Table0
Where Table.DEPTH > 5;
To get table aliases when there is more than one table for a feature, click Get
Aliases in the Import dialog.
Column types
To write a condition, you may need the type of a given column. To get column
types, click Describe Table in the Import dialog box to get information about
any table in the current schema.
To create a query
2 Type a WHERE clause in the edit control below the Condition Samples
list.
The WHERE clause is applied to each of the selected features as it is typed,
without checking to see if it is valid. If the condition is not valid — for
example, if it references a table that does not belong to the feature — the
query fails when it executes.
■ Click Load.
This action loads a query from the table ADMPIMPORTSETTINGS in the
current schema and displays its SQL statement in a separate dialog box.
You can't execute the query, but you can view it, and you can copy parts
of it to use in other queries.
To run a query
■ Click Import.
Note
Keep in mind that the purpose of this application is to instruct. It lacks
extensive error handling. Use it with caution.
Classes highlighted
It highlights the following Oracle Spatial classes.
AcMapOSEExportReactor
The following classes are included also, but their use is less extensive.
AcMapOSEConnection
Note
Keep in mind that the purpose of this application is to instruct. Use it with
caution. It lacks extensive error handling, and it may bog down when the
data set is large.
Classes Highlighted
It highlights the following Oracle Spatial classes.
AcMapOSEConnection AcMapOSEImportReactor AcMapOSEExportReactor
AcMapOSEObject
The following classes are included also, but their use is less extensive.
AcMapOSEImport AcMapOSEExport AcMapOSEQuery
AcMapOSEConnectionReactor
Note
The sample assumes that features are already defined completely using our
MAPOSEADMIN command.
Keep in mind that the purpose of this application is to instruct. Use it with
caution. It lacks extensive error handling, and it may bog down when the
data set is large.
Topology Detail
A node topology defines the interrelation of nodes (point objects). Node topologies
often are used in conjunction with other topologies in analysis. Examples of
node topologies include street lights, city-maintained trees, or drill holes for
core samples. A network topology considers the interconnection of links (lines)
forming a linear network. Links can connect nodes. Examples of network
topologies include a street network and a water-distribution application that
traces the flow of water from a pumping station to residences. A polygon topology
defines polygons that represent enclosed areas such as land parcels and census
tracts. A single link defines the common boundary between adjacent areas. A
polygon topology can be used for tax assessment and land planning in which
parcels of land are represented by polygons. Polygon topologies can represent
political boundaries, such as voting districts, city, state, or provincial boundaries,
special districts, and school districts.
With topologies, you can perform spatial analyses such as:
■ Find the area within a certain distance of map features (by creating buffers)
109
Topology information is stored as object data on each element that makes up
the topology. This data can be saved as part of the current map, or saved back
to a source drawing. Because topology is definable for a map, identifiers used
to store the topology are unique to the map. Topology in each drawing must
be separate and unique. Autodesk Map does not support topology data that
spans several drawing files (such as tiled maps) unless they are combined in
a project.
You must create centroids for mpolygons and closed polylines before building
a topology with them.
See Creating Centroids.
You must clean drawing objects before building a topology with them.
See Drawing Cleanup.
■ Open a topology in the current drawing - Open(). See also EOpenMode enum.
■ Open a topology in the current and source drawings - Open(). See also
EOpenMode enum and EAuditResults enum.
■ Completeness - IsComplete()
■ Description - GetDescription()/SetDescription()
■ Highlighting - ShowGeometry()
■ Name - GetName()/Rename()
■ Source - GetTopologySource()/GetSource()
■ Type -
GetType()/IsFixedType()/IsLinearType()/IsLogicalType()/IsPointType()/IsPolygonType().
See also ETopologyType enum.
Querying Topologies
AcMapTopologyAcMapTopoFullEdgeAcMapTopoNodeAcMapTopoPolygon
■ Flood trace - A network flood trace traces out from a point in all directions,
given the point where the network starts and the maximum distance that
the network can traverse. A flood trace determines how many links and
nodes can be traveled before the accumulated resistance exceeds the
specified maximum resistance. You can find all restaurants within a
10-minute walk of a hotel, for example, or check the integrity of a network
topology (if some links are not flooded, the topology is incomplete). Use
TraceFlood() to calculate a flood trace and an AcMapFloodParameters instance
to set trace parameters.
■ Erase() - An erase operation uses the overlay polygon topology like a mask
and erases everything in the source polygon topology that is covered by
the overlay topology.
Handling Errors
Many functions in the various topology classes return an AcMap::EErrCode
error code. When a particular function returns an error code, read that
function's documentation for function-specific error conditions rather than
relying on only the generic error descriptions in the AcMap::EErrCode
documentation.
■ For more information about topology in AutoCAD Map 3D, choose Help
> AutoCAD Map 3D Help > Contents tab (or press F1), and then navigate
to Using AutoCAD Map 3D (by feature) > Topology (Spatial Analysis).
■ For a topology tutorial in AutoCAD Map 3D, choose Help > Tutorials >
Contents tab, and then choose "Using Topology and Spatial Analysis".
■ For information about object data in AutoCAD Map 3D, choose Help >
AutoCAD Map 3D Help > Contents tab (or press F1), and then navigate to
Using AutoCAD Map 3D (by feature) > Object Data.
Topology Samples
To view code samples of topology functions, open the Samples folder in your
AutoCAD Map 3D ObjectARX installation and navigate to Map
Samples\Topology.
Creating Centroids
You must create centroids for mpolygons and closed polylines before building
a topology with them.
A closed polyline is a polygon produced by the POLYGON command.
Creating Centroids on page 127
Other Information Sources
Creating Centroids Samples on page 128Creating Centroids Namespace on page
128
Creating Centroids
Use the CreateCentroids() (twoforms) functions in the AcMapUtilities namespace
to create centroids.
For centroid-creation source-code samples, see Creating Centroids Samples on
page 128.
■ For more information about creating centroids in AutoCAD Map 3D, choose
Help > Autodesk Map Help > Contents tab (or press F1), and then navigate
to Using AutoCAD Map 3D (by feature) > Topology (Spatial Analysis) >
Editing Topologies > Creating Centroids for Polygons.
127
Creating Centroids Samples
To view code samples of centroid-creation functions, open the Samples folder
in your AutoCAD Map 3D ObjectARX installation and navigate to Map
Samples\CreateCentroid.
2 Allocate memory for cleanup variables, which specify properties for the
cleanup process. The variables are initialized to their default values. Use
tpm_varalloc.
ade_id cleanupVarId = tpm_varalloc();
If you will be specifying an explicit list of cleanup actions (you create and
manage this list with calls to tpm_cleanactionlistins and related functions),
also allocate memory for cleanup action variables, which specify properties
for individual actions. Again use tpm_varalloc.
ade_id cleanupActionVarId = tpm_varalloc();
129
RTDXF0, "LWPOLYLINE",
8, "UtilityNetwork-Electric",
0);
ads_name ssObjsForCleanup;
acedSSGet("X", NULL, NULL, pFilteredEntitySelectionRb,
ssObjsForCleanup);
acutRelRb(pFilteredEntitySelectionRb);
You can also get a selection set of objects to be anchored (the anchor set).
Anchored objects are not repositioned by the cleanup process, but remain
fixed while others are repositioned around them.
ads_name ssObjsToAnchor;
acutPrintf("\nSelect the objects to serve as an anchor.");
acedSSGet(NULL, NULL, NULL, NULL, ssObjsToAnchor);
The acedSSGet function prompts the user to select objects and returns a
selection set. This function can also be used with a resbuf to filter selected
objects. Make sure to release selection sets when finished with them,
using acedSSFree()
4 Set cleanup variables using tpm_varset with the clean_var_id that you
allocated in step 2. A few of these variables specify cleanup actions, but
most of them specify how cleanup actions will be performed.
// Set the cleanup variable "LINK_ERROR" for break crossing.
char* pszConfigVarName = "LINK_ERROR";
struct resbuf* pLinkErrorVarValRb = acutBuildList(
RTSHORT, 2,
0);
int resultCode = tpm_varset(
cleanupVarId,
pszConfigVarName,
pLinkErrorVarValRb);
acutRelRb(pLinkErrorVarValRb);
// Set the cleanup variable "INCLUDEOBJS_AUTOSELECT".
// Must be included with a filtered selection set.
pszConfigVarName = "INCLUDEOBJS_AUTOSELECT";
struct resbuf* pIncludeObjsVarValRb = acutBuildList(
RTSHORT, 0,
0);
resultCode = tpm_varset(
cleanupVarId,
pszConfigVarName,
pIncludeObjsVarValRb);
acutRelRb(pIncludeObjsVarValRb);
5 Call tpm_cleaninit to add cleanup variables and the selection set of objects
to clean to the cleanup model.
resultCode = tpm_cleaninit(
cleanupModelId,
cleanupVarId,
ssObjsForCleanup);
Annotation Details
Use AutoCAD Map 3D's annotation feature to indicate textual values on a
drawing object.
Creating Annotation Templates on page 135
Setting Annotation Template Properties on page 136
Setting Annotation Text and Expressions on page 137
Inserting Annotation References on page 138
Updating Annotations on page 139
Deleting Annotations on page 140
Managing Annotations on page 141
Other Information Sources on page 142
Annotation Samples on page 142Annotation Namespace on page 142
135
information will be included and how it will be displayed. Call
AnnotationTemplateExists() to check whether a specific template already exists;
if it does exist, CreateAnnotationTemplate() won't overwrite it, but rather will
return a null object ID.
For annotation source-code samples, see Annotation Samples on page 142.
char* pszTemplateName = "MyAnnotationTemplate";
AcDbObjectId idCreatedAnnTem;
if(!AnnotationTemplateExists(pszTemplateName))
{
// Create a template with the name stored in pszTemplateName.
idCreatedAnnTem = CreateAnnotationTemplate(pszTemplateName);
// Test whether the template's object ID is valid.
if(idCreatedAnnTem != AcDbObjectId::kNull)
{
}
}
■ Color - GetTemplateColor()/SetTemplateColor()
■ Layer - GetTemplateLayer()/SetTemplateLayer()
■ Linetype - GetTemplateLinetype()/SetTemplateLinetype()
■ Lineweight - GetTemplateLineWeight()/SetTemplateLineWeight()
■ Rotation - GetTemplateRotation()/SetTemplateRotation()
Updating Annotations
If an entity associated with an annotation reference changes, call
RefreshAnnotationReferences() to refresh the annotation. If an annotation
template changes, call UpdateAnnotationReferences() to update the annotation
references based on that template. Both functions let you control how the
annotation reference's property values are updated.
For annotation source-code samples, see Annotation Samples on page 142.
Deleting Annotations
To delete an annotation template, call DeleteAnnotationTemplate(). You can
delete only templates with no annotation references, which you can check
with IsAnnotationTemplateReferenced().AnnotationTemplateReferencedObjIds()
lists all of a template's references, which you must delete before you can delete
the template. Delete an annotation reference in the same way that you would
delete any AutoCAD object.
For annotation source-code samples, see Annotation Samples on page 142.
Managing Annotations
You can use several general functions to manage annotation templates and
references.GetTemplateNames() lists the annotation templates defined in the
current drawing. Autodesk Map stores an annotation template as a block
(AcDbBlockTableRecord) and an annotation reference as a block reference
(AcDbBlockReference).
■ For more information about annotation in AutoCAD Map 3D, choose Help
> Autodesk Map Help > Contents tab (or press F1), and then navigate to
Using AutoCAD Map 3D (by feature) > Annotation.
■ For an annotation tutorial in AutoCAD Map 3D, choose Help > Tutorials
> Contents tab, and then choose "Adding Annotations to Objects".
■ For more information about expressions in AutoCAD Map 3D, choose Help
> Autodesk Map Help > Contents tab (or press F1), and then navigate to
Expression Evaluator.
Annotation Samples
To view code samples of annotation functions, open the Samples folder in
your AutoCAD Map 3D ObjectARX installation and navigate to Map
Samples\Annotation.
Annotation Namespace
To view the annotation namespace, click the following link:
AcMapAnnotationManager Namespace
143
144
User Management
26
The AutoCAD Map 3D user-management feature provides user- and session-management
tools for system administrators.
User Management
The AcMapSession class provides the following user and session functions. The
AcMapGetSession() global function retrieves the AutoCAD Map 3D session pointer,
an instance of AcMapSession.
145
■ Retrieve/set workspace rectangle - GetWSpaceRectangle()/SetWSpaceRectangle()
■ For more information about user management in AutoCAD Map 3D, choose
Help > Autodesk Map Help > Contents tab (or press F1), and then navigate
to Using AutoCAD Map 3D (by feature) > Setting Up AutoCAD Map 3D
Drawings > Setting Options > Setting Up Users.
■ Map Book sample code, which is located in the Map Samples\Plotting folder
of Autodesk Map ObjectARX installations.
149
150
Managed Wrapper Classes
28
ObjectARX presented as managed C++.
151
To get or set the same option in managed wrapper context, first use the
MapApplication::Options property to get the SystemOptions object, and then
use an option-specific SystemOptions property:
oSysOptions.LogFileName = "filename.ext";
strLogFile = oSysOptions.LogFileName;
Sample Code
To get managed-wrapper samples, open MapSamples\DotNet in an AutoCAD
Map 3D ObjectARX installation.
Index Name
1 Red
2 Yellow
3 Green
4 Cyan
5 Blue
153
Index Name
6 Magenta
7 White
Logical Colors, which correspond to indexes 0 and 256. The logical colors are
ByBlock (0) and ByLayer (256), and they reflect the current block and layer
colors respectively. For example, "ByBlock" (always double-quoted). Note that
ByBlock and ByLayer can return true colors or ACIs.
For more information about ACIs,
True Colors
By true colors we mean 24-bit color: three RGB components, 8 bits each, with
no alpha component (that is, no transparency value).
The valid true-color formats are
RGB Triplets, where each component is an integer from 0 through 255. For
example, "255,0,0". RGB triplets are wrapped in double quotes except when
they are used in query conditions, in which case they must always be wrapped
in escaped double quotes ('\"'). See "Color Patterns" below.
Color Book Colors, such as "Pantone, 123 CVC", a composite of two
comma-separated names representing a Color Book and a color within it.
Color book strings are wrapped in double quotes except when they are used
in query conditions, in which case they must always be wrapped in escaped
double quotes ('\"'). See "Color Patterns" below. And no matter where they
are used, color book strings must always be wrapped in escaped double quotes
if they contain certain special characters. If you are unsure if a color book
string contains special characters, there is no harm wrapping it in escaped
double quotes just to be sure.
Expressions, such as ".COLOR" or ".TRUECOLOR" (always double-quoted).
".COLOR" always returns an ACI color. If the selected object's color is a true
color it returns the nearest ACI equivalent. ".TRUECOLOR" returns a true color
if the selected object's color is a true color, or an ACI if its color is an ACI.
Note that ".TRUECOLOR", and other expressions that can return true colors,
return in valid format only if the type argument of (ade_expreval) is "string".
NOTE Note You can use wildcard characters when you specify a match string for
Color Book colors (but not for RGB colors). For this reason, any wildcard character
in a Color Book string that is meant to be taken literally must be escaped using a
backquote, "`". For example, the "." character in the following string, normally a
wildcard matching any non-alphanumeric character, is meant as a literal:
"My`.Colors, Hot".
Colors | 155
156
Index
A
annotation 135 I
importing 69
C
centroids 127 L
converting from one coordinate system to labels 135
another 51
coordinate systems 51
about 49 M
coordinate systems, 49
custom objects 35 managing users 145
queryable 33, 35 map plotting 149
custom objects, 33
O
D object data tables
data sources 37 about 39
display manager 143 sample code 41–42, 44–45
drawing cleanup for topology 129 object filters 65
drawing sets objects
about 3 filtering 65
sample code 5 queryable custom objects 33, 35
drawings Oracle Spatial data
about 3 about 79
cleanup for topology 129 sample code 85, 88–89, 92, 94, 98,
sample code 5 103, 105–106
E P
exporting 69 plotting maps 149
points
converting from one coordinate
F system to another 51
property alteration
feature classification 55 about 19
filtering objects 65 sample code 23
protocol extensions for querying custom
objects 35
Index | 157
Q T
queries 11 topology
custom objects and 33, 35 about 109
sample code 15 centroids 127
drawing cleanup for 129
R
U
reactors 79
user management 145
users
S managing 145
subclassing queryable custom objects 33
158 | Index