before you begin - documentation & help · before you begin autocad map 3d objectarx...

Post on 10-May-2020

49 Views

Category:

Documents

5 Downloads

Preview:

Click to see full reader

TRANSCRIPT

BeforeYouBegin

AutoCADMap3DObjectARXDeveloper'sGuidedescribeshowtouseObjectARXclassestoautomateandextendAutoCADMap3D.

AutoCADMap3DObjectARXextendsAutoCADObjectARXintotheAutoCADMap3Ddomain.

TheObjectARXandObjectARX.NETAPIseachcovermostofAutoCADMap3Dfunctionality.Buttheydon'tcoverResourceService,FeatureService,orMappingService.TheseareasarecoveredbytheGeospatialPlatformAPI,whichisexposedas.NETonly.

Topicsinthissection

SourcesofInformationCompatabilityofSDKsTypographicConventions

Pleasesendusyourcommentaboutthispage

SourcesofInformation

TodevelopapplicationsusingAutoCADMap3DObjectARX,youshouldbefamiliarwithAutoCADObjectARXandalsotheAutoCADMap3DandAutoCADapplications.

Forinformationabout...

Referto...

AutoCADObjectARX AutoCADObjectARXHelp,arxdoc.chm,whichislocatedinthedocsfolderofAutoCADMap3DSDKinstallations.

AutoCADMap3DandAutoCAD

AutoCADMap3DHelp,whichislocatedintheHelpfolderofAutoCADMap3Dinstallations.

AutodCADMap3DHelpisespeciallyusefulforundestandinghowAutoCADMap3Dmodelsitsdomain.Forunderstandingdrawingsetsandqueries,forexample.SincedetailedexplanationsoftheseparadigmsareavailableinAutoCADMap3DHelp,AutoCADMap3DSDKHelpexplainsthemonlybrieflyornotatall.BeforeyouattempttoautomateorextendanAutoCADMap3Dfeature,besuretoreviewthesubjectinAutoCADMap3DHelp.

Pleasesendusyourcommentaboutthispage

CompatabilityofSDKs

TheAutoCADMap3DSDKmustbeinstalledinanexistingAutoCADSDKinstallation,andtheAutoCADMap3DSDKandAutoCADSDKversionsmustbecompatiblewitheachotherandwiththeversionofAutoCADMap3Dthatyouareextending.Forexample,theAutoCADMap3D2008SDKmustbeinstalledintoanexistingAutoCAD2008SDKinstallation,andyouneedbothtobuildObjectARXapplicationsforAutoCADMap3D2008.

Pleasesendusyourcommentaboutthispage

TypographicConventions

Textelement Descriptionboldsansserif Textyouenteratthe

AutoCADMap3Dcommandprompt.

italic Namesoffilesanddirectories.

monospacefont Samplecode.

Note NoteAllfilenamesanddirectorypathsinAutoCADMap3Darecasesensitive.

Pleasesendusyourcommentaboutthispage

DrawingSets

Thecollectionofdrawingsusedinaparticularprojectistheproject'sdrawingset.

Topicsinthissection

DrawingSetsDetail

Pleasesendusyourcommentaboutthispage

DrawingSetsDetail

Whenyousaveaproject,AutoCADMap3Dautomaticallysavesreferencestoalltheproject'sdrawingsetfilesintheproject'sDWGfile.

Youattachdrawingstoanddetachdrawingsfromadrawingset.

AttachedDrawings

Adrawingsetisatreeofattacheddrawings.Anyoftheattacheddrawingscanhaveotherdrawingsattachedtothem.Thedrawingsthatarenotdirectlyattachedtotherootofthedrawingset(atlevel0ofthetree)arecallednesteddrawings.

YoucanuseAcMapDrawingSetfunctionstoeditandmanipulateonlydrawingsthataredirectlyattachedtothedrawingsetattherootlevel(level0)ofthedrawingset.Toaccessandeditdrawingsatdeeperlevels,usethefunctionsoftheAcMapAttachedDrawingclass.

Asingledrawingcanbedirectlyattachedtothedrawingsetonlyonce.However,asingledrawingcanhavemultipleentriesinthedrawingsetatnestedlevels1anddeeper.

Youcandesignateanattacheddrawingasactiveorinactive.Whenaqueryisexecutedintheproject,onlytheactivedrawingsareconsidered.Whenyouworkwithobjectdatainaproject,opendrawingsinsteadofattachingthem.

DrawingSetReactors

Youcanattachareactortoadrawingset.Adrawingsetreactornotifiesanapplicationaboutdrawingset-relatedevents,suchasattachment,detachment,activation,ordeactivation.Wheneverthedrawingsetismodified,anappropriatefunctionofthereactorobjectiscalledbeforeterminationofthezerolevelMaptransaction.

SavingAttachedDrawings

If,aftermodifyinganattacheddrawing,youwanttosavethechangesinthesourcedrawing,youmustspecifythesetofdrawingobjectstobesavedinasaveset.

Savinganattacheddrawingwithitsdrawingobjectsistypicallyathree-partprocedure:

1. LockthedrawingforwritingusingAcMapAttachedDrawing::LockForWrite.

2. ClonethedrawingobjectsthatyouwishtosaveusingoneoftheAcMapAttachedDrawingclass'sfunctions.

3. Savethechangesbacktothedrawing'ssourcefileusingAcMapAttachedDrawing::Save.

ForMoreInformation

Formoreinformationaboutdrawingsets,seetheUIdocumentation,AutodeskMapHelp.

Pleasesendusyourcommentaboutthispage

DrawingSetSample

Topicsinthissection

DrawingSetSample

Pleasesendusyourcommentaboutthispage

DrawingSetSample

Thefollowingsampledemonstratesdrawingsetoperations.

voideditDSet()

{

AcMapSession*mapApi;

AcMapProject*pProj;

AcMapDrawingSet*pDSet;

charres[32];

do{

mapApi=AcMapGetSession();

if(mapApi==NULL)

{

acutPrintf("\nCan'tconnectMAP");

break;

}

if(mapApi->GetProject(pProj)==Adesk::kFalse)

{

break;

}

if(pProj->GetDrawingSet(pDSet)==Adesk::kFalse)

{

acutPrintf("\nCan'tgetdrawingset");

break;

}

do{

//Setup

printDSet(pDSet);

*res=EOS;

acedInitGet(

0,

"eXitaTtachDetachActivatedeaCtivateSettings

gettaBleaLiasesViewPreviewReportQueryZoom");

if(acedGetKword(

"\naTtach/Detach/Activate/deaCtivate/

Settings/gettaBle/aLiases/View/Preview/Report/

Query/Zoom/<eXit>:",

res

)==RTNORM)

{

if(*res==EOS||!(strcmp(res,"eXit")))

{

break;

}

//Attachadrawing

elseif(!strcmp(res,"aTtach"))

{

if(acedGetString(

1,

"Enteraliaspath:",

res

)==RTNORM)

{

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->AttachDrawing(pDwg,res)==AcMap::kOk)

{

deletepDwg;

}

}

}

//Detachadrawing

elseif(!strcmp(res,"Detach"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

pDSet->DetachDrawing(res);

}

//Activateadrawing

elseif(!strcmp(res,"Activate"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->GetDrawing(

pDwg,

res,

Adesk::kFalse

)==AcMap::kOk)

{

pDwg->Activate();

deletepDwg;

}

}

//Deactivateadrawing

elseif(!strcmp(res,"deaCtivate"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->GetDrawing(

pDwg,

res,

Adesk::kFalse

)==AcMap::kOk)

{

pDwg->Deactivate();

deletepDwg;

}

}

//Getadrawing'ssymboltable

elseif(!strcmp(res,"gettaBle"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->GetDrawing(

pDwg,

res,

Adesk::kFalse

)==AcMap::kOk)

{

getTable(pDwg);

deletepDwg;

}

}

//Editadrawing'ssettings

elseif(!strcmp(res,"Settings"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->GetDrawing(

pDwg,

res,

Adesk::kFalse

)==AcMap::kOk)

{

editSettings(pDwg);

deletepDwg;

}

}

//Previewallofadrawing

elseif(!strcmp(res,"View"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->GetDrawing(

pDwg,

res,

Adesk::kFalse

)==AcMap::kOk)

{

pDwg->Preview();

deletepDwg;

}

}

//Previewqueriedobjectsinadrawing

elseif(!strcmp(res,"Preview"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->GetDrawing(

pDwg,

res,

Adesk::kFalse

)==AcMap::kOk)

{

AcDbObjectIdArraytIds;

pDwg->ApplyQuery(tIds);

pDwg->Preview(tIds);

deletepDwg;

}

}

//Createareportofthequeriedobjectsinadrawing

elseif(!strcmp(res,"Report"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->GetDrawing(

pDwg,

res,

Adesk::kFalse

)==AcMap::kOk)

{

AcDbObjectIdArraytIds;

pDwg->ApplyQuery(tIds);

pDwg->Report(tIds);

deletepDwg;

}

}

//Copythedrawingobjectsmatchingthe

//currentquerytotheprojectdrawing

elseif(!strcmp(res,"Query"))

{

acedGetString(1,"Enterdrawingpath",res);

AcMapAttachedDrawing*pDwg=NULL;

if(pDSet->GetDrawing(

pDwg,

res,Adesk::kFalse

)==AcMap::kOk)

{

AcDbObjectIdArraytIds;

pDwg->ApplyQuery(tIds);

pDwg->QueryIn(tIds);

deletepDwg;

}

}

//Zoomthedrawingstothemaximum

elseif(!strcmp(res,"Zoom"))

{

pDSet->ZoomExtents();

}

}

else

{

break;

}

printErrStack();

}while(1);

}while(0);

}

Pleasesendusyourcommentaboutthispage

Queries

Aqueryisthemechanismbywhichtheapplicationretrievesasubsetofobjectsfromasourcedrawing,orfromanexternaldatabaseassociatedwithasourcedrawing,foruseintheprojectdrawing.

Topicsinthissection

QueriesDetail

Pleasesendusyourcommentaboutthispage

QueriesDetail

Afteraqueryhasbeendefined,itcanbesavedexternallyandsubsequentlyloadedintoanapplication,whereitcanbeexecutedormodified.

Thebuildingblocksforcreatingaquerydefinitionarequeryconditionsandquerybranches.

QueryConditions

Thecriteriathatthequeryusestoselectobjectsareexpressedinqueryconditions.Therearefourtypesofqueryconditions.

DescriptionLocationConditions Basedonthelocation

ofobjectsrelativetoaboundary.Thereareseveralboundarytypes.SeeLocationBoundariesbelow.

PropertyConditions BasedonaparticularAutoCADproperty.

DataConditions Basedonobjectdata?informationaboutdrawingobjectsthatisstoredwithdrawingobjectsthemselves.

SQLConditions Basedondataaboutdrawingobjectsthatisstoredinexternaldatabasetablesandis

specifiedbytheWHEREclauseofaSQLquery.

LocationBoundaries

Thereareseveraltypesoflocationboundaries.TheyareallrepresentedbydescendentsoftheAcMapLocationBoundaryclass,asillustratedinthefollowingdiagram.

Formoreinformationaboutqueryconditiontypes,refertoAutoCADMap3DHelp.OntheContentstab,clickUsingAutoCADMap3D>Queries>DefiningQueries.

QueryBranches

Querybranchesaretreescomposedofqueryconditions,possiblysubordinatequerybranches,andjoinoperators,whichconnectthecomponents.

Thefollowingdiagramillustratesthestructureofasimplequerybranch,inwhicha,b,andcarequeryconditionsandANDandORarejoinoperators.Itexpressesthequery,aANDborc.

Bothquerybranchesandqueryconditionsinheritfromthesamebaseclass,asshowninthefollowingdiagram.

Tobuildaquery

1. Createoneormorequeryconditions(alsocalledqueryunitsoroperands).

2. Createoneormorequerybranches.

3. Appendorinsertqueryconditionsontothebranch(es).

4. CreatethequerydefinitionbypassingthequerybranchtotheAcMapQuery::Definefunction.

5. CreatethequeryasanobjectintheprojectusingtheAcMapProject::CreateQueryfunction.Thismakesthequeryavailableto

theapplication.

6. Savethequerydefinitioninanexternalfileorquerylibrary.

Toexecuteaquery

1. Youmaywanttosetthemode,enableordisablepropertyalteration,orcreateareporttemplateforthequery.

2. CallAcMapQuery::Runtoexecutethequery.

ForMoreInformation

Formoreinformationaboutqueries,seetheUIdocumentation,AutoCADMap3DHelp,andtheMapSamplesfolderofObjectARXinstallations.

Pleasesendusyourcommentaboutthispage

QuerySample

Thefollowingsampledemonstratesqueryoperations.

Topicsinthissection

QuerySampleCode

Pleasesendusyourcommentaboutthispage

QuerySampleCode

AcMapProject*pProj=NULL;

//Createanewbranchobject

AcMapQueryBranch*pRootBranch=NULL;

pRootBranch=newAcMapQueryBranch(AcMap::kOperatorOr);

//Createanewpropertycondition

constchar*pcValuePC="Layer1";

AcMapPropertyCondition*pPropertyCondition=NULL;

pPropertyCondition=newAcMapPropertyCondition(

AcMap::kOperatorOr,

AcMap::kLayer,

AcMap::kCondEq,

pcValuePC

);

AcMapSession*pMapSession=NULL;

AcMapQuery*pNewQuery=NULL;

//Getthesessionobject

pMapSession=AcMapGetSession();

if(pMapSession)

{

//Getthecurrentlyactiveproject

if(pMapSession->GetProject(pProj)==AcMap::kOk)

{

//Createanewqueryobject

if(pProj->CreateQuery(

pNewQuery,

Adesk::kFalse)==AcMap::kOk)

{

//Createanewpropertycondition

constchar*pcValuePC="Layer1";

AcMapPropertyCondition*pPropertyCondition=NULL;

pPropertyCondition=newAcMapPropertyCondition(

AcMap::kOperatorOr,

AcMap::kLayer,

AcMap::kCondEq,

pcValuePC

);

//Createanewbranchobject

AcMapQueryBranch*pBranch=NULL;

pBranch=newAcMapQueryBranch();

//Appendtheconditiontothebranch

pBranch->AppendOperand(pPropertyCondition);

//Definethebranchinthequery

if(pNewQuery->Define(pBranch)==AcMap::kOk)

{

//Runthequery.

pNewQuery->Run();

}

//Cleanup

deletepPropertyCondition;

deletepBranch;

deletepNewQuery;

}//if(pProj->CreateQuery

}//if(pMapSession->GetProject

}//if(pMapSession)

Pleasesendusyourcommentaboutthispage

PropertyAlteration

Propertyalterationdoesnotaffectcorrespondingobjectsinthesourcedrawingordrawings(unlessyoudeliberatelysavethequeriedobjectsback).Theprocessiscontrolledbyasetofoneormorepropertyalterations,eachofwhichdescribeshowaparticularpropertyofqueriedobjectsshouldbedisplayed.Allthepropertyalterationsforaparticularqueryarecontainedinthequery'spropertyalterationdefinition.

Topicsinthissection

PropertyAlteration

Pleasesendusyourcommentaboutthispage

PropertyAlteration

YouassociateapropertyalterationdefinitionwiththequerythatitaffectsusingtheAcMapQuery::GetPropertyAlterationfunction.Youcreateapropertyalterationandaddittothedefinition,withtheAcMapPropertyAlterationDefinition::AddAlterationfunction.

Theclassesusedtocreateandmanipulatepropertyalterationforaqueryare

AcMapPropertyAlterationDefinitionAcMapPropertyAlterationAcMapTextAlterationAcMapHatchAlteration

Thelasttwoclasses,whicharesubclassedfromAcMapPropertyAlteration,arespecializedpropertyalterationsforaddingtextlabelsandhatchpatternstoqueriedobjects.

Youcanalterpropertiesconditionally,dependingonexistingvaluesofthepropertytobealteredorofsomeotherproperty.Todoso,youwillalsoneedtousethefollowingclasses:

AcMapRangeLibraryAcMapRangeTableAcMapRangeLine

PropertyTypes

Apropertyalteration'stypeidentifiesthepropertythatitalters.ThepropertiesthatcanbealteredareenumeratedinAcMap::EAlterationType.Whenyoucreateapropertyalteration,yousetitstypebyassigningitoneoftheseenumerators.Notethattwooftheseenumerators,AcMap::kAlterationTextEntityandAcMap::kAlterationHatch,createthespecializedpropertyalterationobjectsAcMapTextAlterationandAcMapHatchAlteration,whicharesubclassedfromAcMapPropertyAlteration.TheremainingenumeratorssimplyidentifythedifferentkindsofAcMapPropertyAlterationobjects,thesimplepropertyalterations.

AcMapTextAlterationobjectsinapropertyalterationdefinitioncreatetext

objectswhenthequeryexceutes,whichserveastextlabelsforqueriedobjects.AcMapHatchAlterationobjectscreatehatchobjects,whichapplyhatchpatternstoclosedorcloseablequeriedobjects.

Thevaluethatthepropertyacquireswhenthequeryisrunisindicatedbythepropertyalteration'svalueexpression,whichyousetwiththeAcMapPropertyAlteration::SetExpressionfunction.Forexample,ifthepropertyalteration'stypeisAcMap::kAlterationColor,youmightsetitsexpressionto"Red".Ifthepropertyalteration'stypeisAcMap::kAlterationTextEntity,thepropertyalteration'svalueexpressionisthetextforthelabel.IfthetypeisAcMap::kAlterationHatch,thevalueexpressionisapatternname.

Todefineapropertyalterationforaquery

1. GetthepropertyalterationdefinitionofthequeryusingtheAcMapQuery::GetPropertyAlterationfunction.

2. CreateapropertyalterationandaddittothepropertyalterationdefinitionusingtheAcMapPropertyAlterationDefinition::AddPropertyAlterationfunction.

3. Setthepropertyalteration'sexpressionusingtheAcMapPropertyAlteration::SetExpressionfunction.

4. Repeatsteps2and3foreverypropertyalterationthatyouwanttobeexecutedbythequery.

ApplyingPropertyAlteration

Whenthequeryisexecuted,propertyalterationisappliedonlyifitisdefinedandenabled.UsethefollowingAcMapQueryfunctionstodeterminewhetherpropertyalterationhasbeendefinedforaquery,whetherithasbeenenabled,andtoenableordisableitasneeded.

AcMapQuery::IsPropertyAlterationDefinedAcMapQuery::IsPropertyAlterationEnabledAcMapQuery::EnablePropertyAlteration

Propertyalterationisdefinedifthequery'spropertyalterationdefinitioncontainsatleastonepropertyalteration.

ConditionalPropertyAlteration

Youcanalterpropertiesconditionally,dependingonexistingvaluesofthepropertytobealteredorofsomeotherproperty.Forexample,youcanalterthecolorsofqueriedparcelsdependingontheirassessedvalue.

Arangetableisacollectionofrangelines.Arangelineconsistsofacomparativeoperator(suchas"greaterthan"),acomparisonvalue(suchas1,000,000),andareturnvalue(suchas"Green"),toexpressaconditionalalterationsuchas,"Ifthevalueisgreaterthan1,000,000,returngreen."Tousearangetable,passarangetableexpressiontothepropertyalteration'sSetExpressionfunction.Arangetableexpressionhasthefollowingformat.

whereRangeisaninvariantkeyword.

Alltherangetablesavailabletoaprojectarecontainedintheproject'srangelibrary,aninstanceoftheAcMapRangeLibraryclass.Aprojectcontainsasinglerangelibrary.

ForMoreInformation

Formoreinformationaboutpropertyalterationandrangetables,seetheUIdocumentation,AutoCADMap3DHelp,andtheMapSamplesfolderofObjectARXinstallations.

ThepropertyalterationfeatureofAutoCADMap3Dletsyoumodifytheappearanceofobjectsqueriedintotheprojectdrawing.

Pleasesendusyourcommentaboutthispage

PropertyAlterationSample

Thisexampleshowshowtocreaterangelinesandalterations.

Topicsinthissection

PropertyAlterationSample

Pleasesendusyourcommentaboutthispage

PropertyAlterationSample

Italsoshowshowtousethemtogetherwithaquery.Itassumesthereisacurrentproject,aprojectdrawing,andatleastoneactiveattacheddrawingwithsomedrawingobjectsinit.

////////////////////////////////////////

//MAINLOOP

//

//Clearsthecurrentqueryandcalls

//DefineRangeLines(),TextAlt(),and

//HatchAlt().

//

////////////////////////////////////////

voiddoPropAlts()

{

AcMapSession*mapSession=NULL;

mapSession=AcMapGetSession();

if(mapSession)

{

AcMapProject*pProj;

if(mapSession->GetProject(pProj)==Adesk::kTrue)

{

//GetthecurrentQuery

AcMapQuery*pCurrentQuery=NULL;

if(pProj->CreateQuery(

pCurrentQuery,

Adesk::kTrue

)==AcMap::kOk)

{

//Beforewestart,clearthecurrentquery

pCurrentQuery->Clear(Adesk::kTrue);

//cleanup

deletepCurrentQuery;

}

}

}

//makethecalls

DefineRangeLines()

TextAlt()

HatchAlt()

}

////////////////////////////////////

//DefineRangeLines()

//

//Createstworangetablesand

//addsthemtotherangelibrary

//

////////////////////////////////////

voidDefineRangeLines()

{

AcMapSession*mapSession=NULL;

try

{

mapSession=AcMapGetSession();

if(mapSession)

{

AcMapProject*pProj;

if(mapSession->GetProject(pProj)==Adesk::kTrue)

{

//Gettherangelibrary

AcMapRangeLibrary*pRangeLib=NULL;

if(pProj->GetRangeLibrary(pRangeLib)==Adesk::kTrue)

{

//Addarangetabletothelibrary

AcMapRangeTable*pTable=NULL;

constchar*pcName="MyTypeRangeTable";

constchar*pcDsc="Tablefortypes";

if(pRangeLib->AddRangeTable(

pTable,

pcName,

pcDsc

)=AcMap::kOk)

{

//Addrangelinesthatwilladdtextnextto

//entitesthatmatchtheinputcriteria.

pTable->AddRangeLine(

AcMap::kRangeEq,

"circle",

"CIRCLE");

pTable->AddRangeLine(

AcMap::kRangeEq,

"polygon",

"POLYGON");

pTable->AddRangeLine(

AcMap::kRangeEq,

"polyline",

"PLINE");

pTable->AddRangeLine(

AcMap::kRangeEq,

"line",

"LINE");

pTable->AddRangeLine(

AcMap::kRangeEq,

"lwpolyline",

"LWPOLYLINE");

pTable->AddRangeLine(

AcMap::kRangeEq,

"text",

"TEXT");

pTable->AddRangeLine(

AcMap::kRangeOtherwise,

NULL,

"UnknownType");

}

//cleanup

if(NULL!=pTable)

{

deletepTable;

pTable=NULL;

}

pcName="MyHatchRangeTable";

pcDsc="Tableforhatchranges";

if(pRangeLib->AddRangeTable(

pTable,

pcName,

pcDsc

)==AcMap::kOk)

{

//Addrangelinesthatwilladdhatchpatterns

//toentitesthatmatchtheinputcriteria.

pTable->AddRangeLine(

AcMap::kRangeEq,

"circle",

"ANSI31");

pTable->AddRangeLine(

AcMap::kRangeEq,

"polygon",

"CROSS");

pTable->AddRangeLine(

AcMap::kRangeEq,

"polyline",

"ANSI33");

pTable->AddRangeLine(

AcMap::kRangeEq,

"lwpolyline",

"DASH");

pTable->AddRangeLine(

AcMap::kRangeOtherwise,

NULL,

"SOLID");

}

//cleanup

if(NULL!=pTable)

{

deletepTable;

pTable=NULL;

}

}

}

}

}

catch(...)

{

//dosomeerrorhandling

}

}

///////////////////////////////////////////////

//TextAlt()

//

//CreatesaTextAlterationandsetsthe

//expressiontothetable,MyTypeRangeTable.

//Definesandrunsaquerywithproperty

//alteration.

//

///////////////////////////////////////////////

voidTextAlt()

{

AcMapSession*mapSession=NULL;

try

{

mapSession=AcMapGetSession();

if(mapSession)

{

AcMapProject*pProj;

if(mapSession->GetProject(pProj)==Adesk::kTrue)

{

//GetthecurrentQuery

AcMapQuery*pCurrentQuery=NULL;

if(pProj->CreateQuery(

pCurrentQuery,

Adesk::kTrue

)==AcMap::kOk)

{

//GetthePropertyalterationobjectfromthequery

AcMapPropertyAlterationDefinition*pPADef=NULL;

if(pCurrentQuery->GetPropertyAlteration(

pPADef

)==AcMap::kOk)

{

AcMapPropertyAlteration*pPropAltObj=NULL;

//AddaTextAlteration

if(pPADef->AddAlteration(

pPropAltObj,

AcMap::kAlterationTextEntity

)==AcMap::kOk)

{

//Firstweneedtocastit

AcMapTextAlteration*pTextAlt=NULL;

pTextAlt=(AcMapTextAlteration*)pPropAltObj;

//setsomeattributes

pTextAlt->SetColor("Magenta");

pTextAlt->SetJustification("MIDDLE");

pTextAlt->SetRotation("45.0");

pTextAlt->SetHeight("0.5");

pTextAlt->SetExpression(

"(Range.TYPEMyTypeRangeTable)"

);

}

//cleanup

if(pPropAltObj)

{

deletepPropAltObj;

pPropAltObj=NULL;

}

}

//enablepropertyalterationsforthequery

pCurrentQuery->EnablePropertyAlteration(Adesk::kTrue);

//CreateaquerybranchEntityType=ALL

AcMapQueryBranchqBranch;

AcMapPropertyConditionpropCond;

propCond.SetPropertyType(AcMap::kEntType);

propCond.SetConditionOperator(AcMap::kCondEq);

propCond.SetValue("*");

qBranch.AppendOperand(&propCond);

//definethequerybranch

pCurrentQuery->Define(&qBranch);

//setthequerymodetodraw

pCurrentQuery->SetMode(AcMap::kQueryDraw);

//runthequery

pCurrentQuery->Run();

//cleanup

deletepCurrentQuery;

}

}

}

}

catch(...)

{

//dosomeerrorhandling

}

}

////////////////////////////////////////////////

//HatchAlt()

//

//CreatesaHatchAlterationandsetsthe

//expressiontothetable,MyHatchRangeTable.

//Definesandrunsaquerywithproperty

//alteration.

//

////////////////////////////////////////////////

voidHatchAlt()

{

AcMapSession*mapSession=NULL;

try

{

mapSession=AcMapGetSession();

if(mapSession)

{

AcMapProject*pProj;

if(mapSession->GetProject(pProj)==Adesk::kTrue)

{

//GetthecurrentQuery

AcMapQuery*pCurrentQuery=NULL;

if(pProj->CreateQuery(

pCurrentQuery,

Adesk::kTrue

)==AcMap::kOk)

{

//GetthePropertyalterationobjectfromthequery

AcMapPropertyAlterationDefinition*pPADef=NULL;

if(pCurrentQuery->GetPropertyAlteration(

pPADef

)==AcMap::kOk)

{

AcMapPropertyAlteration*pPropAltObj=NULL;

//NowaddaHatchAlteration

if(pPADef->AddAlteration(

pPropAltObj,

AcMap::kAlterationHatch

)==AcMap::kOk)

{

//Firstweneedtocastit

AcMapHatchAlteration*pHatchAlt=NULL;

pHatchAlt=(AcMapHatchAlteration*)pPropAltObj;

//setsomeattributes

pHatchAlt->SetScale("2.0");

pHatchAlt->SetColor("Yellow");

pHatchAlt->SetRotation("45.0");

pHatchAlt->SetExpression(

"(Range.TYPEMyHatchRangeTable)"

);

}

//cleanup

if(pPropAltObj)

{

deletepPropAltObj;

pPropAltObj=NULL;

}

}

//enablepropertyalterationsforthequery

pCurrentQuery->EnablePropertyAlteration(Adesk::kTrue);

//CreateaquerybranchEntityType=ALL

AcMapQueryBranchqBranch;

AcMapPropertyConditionpropCond;

propCond.SetPropertyType(AcMap::kEntType);

propCond.SetConditionOperator(AcMap::kCondEq);

propCond.SetValue("*");

qBranch.AppendOperand(&propCond);

//definethequerybranch

pCurrentQuery->Define(&qBranch);

//setthequerymodetodraw

pCurrentQuery->SetMode(AcMap::kQueryDraw);

//runthequery

pCurrentQuery->Run();

//cleanup

deletepCurrentQuery;

}

}

}

}

catch(...)

{

//dosomeerrorhandling

}

}

//END

Pleasesendusyourcommentaboutthispage

DesigningQueryableCustomObjects

IfyouareusingAutoCADObjectARXtocreateAcDbcustomobjects,youmustmakesurethattheywillberetrievableusingAutoCADMap3Dqueries.

Topicsinthissection

DesigningQueryableCustomObjectsDetails

Pleasesendusyourcommentaboutthispage

DesigningQueryableCustomObjectsDetails

Observethefollowingguidelines:

SubclasseachcustomobjectclassfromtheappropriateARXparentclass,asdetailedbelow.

EnsurethateachcustomobjectinstanceinadrawingisaddedtotheModelSpacesectionofthedrawing'sBlocktable.

TosupportSQLorDataqueries,theparentclassdoesn'tmatter.

Tosupportlocationqueries,acustomclassmustderivefromAcDbEntityandoverloadthemethodsgetGeomExtents,intersectWith,getStretchPoints,andtransformBy.

Tosupportpropertyqueries,customclassrequirementsdependonthepropertiestobequeried:

QueryableProperty ClasstoDeriveFrom MethodstoOverloadArea AcDbCurve getAreaBlockName AcDbBlockReference NoneElevation Notsupported. ObjectType AcDbEntity NoneLength AcDbCurve getEndParam

getDistAtParamTextStyle AcDbText NoneTextValue AcDbText NoneThickness Notsupported. Color AcDbEntity NoneGroup AcDbEntity None

Layer AcDbEntity NoneLinetype AcDbEntity None

NoteObjectTypenamespecifiedviaspecialMACRO,suchasACRX_DXF_DEFINE_MEMBERS.

Pleasesendusyourcommentaboutthispage

CustomObjectProtocolExtensions

EnablescustomobjectstoparticipateinAutoCADMap3DoperationssuchasQueryandSaveBack.

Formoreinformation,see

CustomObjectProtocolExtensionsinAutoCADMap3DObjectARXReferenceHelp.

CustomObjectPEsamplecode,whichislocatedintheMapSamples\QueryPESamplefolderofAutoCADMap3DObjectARXinstallations.

Pleasesendusyourcommentaboutthispage

DataSources

TheAutoCADMap3Ddata-sourcesfeaturelinksinformationfromanexternaldatabasetoobjectsinadrawing.

DataSources

OtherInformationSources

DataSourcesSamplesDataSourcesClass

DataSources

TheAcMapDataSourcesclassprovidesthefollowingdata-sourcesfunctions:

Constructor/destructor-AcMapDataSources()/~AcMapDataSources()

Attachdatasource-AttachDataSource()

Detachdatasource-DetachDataSource()

Detachalldatasources-DetachAllDataSources()

Connectdatasource-ConnectDataSource()

Disconnectdatasource-DisconnectDataSource()

Disconnectalldatasources-DisconnectAllDataSources()

Countattacheddatasources-GetAttachedDataSourcesCount()

Countconnecteddatasources-GetConnectedDataSourcesCount()

Retrieveconnecteddatasources-GetConnectedDataSources()

Retrievedisconnecteddatasources-GetDisconnectedDataSources()

Retrieveattacheddatasources-GetAttachedDataSources()

Fordata-sourcessource-codesamples,seeDataSourcesSamples.

Backtotop

OtherInformationSources

FormoreinformationaboutdatasourcesinAutoCADMap3D,chooseHelp>AutodeskMapHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>ExternalDatabases>AttachingandConfiguringDataSources.

Foradata-sourcestutorialinAutoCADMap3D,chooseHelp>Tutorials>Contentstab,andthenchoose"WorkingwithExternalDatabases".

Backtotop

DataSourcesSamples

Toviewcodesamplesofdata-sourcesfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\DataSource.

Backtotop

DataSourcesClass

Toviewthedata-sourcesclass,clickthefollowinglinks:

AcMapDataSourcesClass

Backtotop

Pleasesendusyourcommentaboutthispage

ObjectData

Objectdataisnon-graphicalinformationaboutanobjectinadrawing.

Whenyouwanttoaddsuchdatatoadrawingordrawingobject,youcreateanobjectdatatabletostorethedata.

Asingleobjectdatatablecontainsrecordsofasimilarstructure,whichisdefinedbytheobjectdatatable'stabledefinition.Theindividualrecordsinanobjectdatatablemaybeassociatedwithdifferentdrawingobjects.Theassociationbetweenthedataandtheobjectisattheleveloftheindividualrecord,notatthetablelevel.

Theclassesusedtocreateandmanipulateobjectdatatablesare

AcMapODColumnDefinitionAcMapODContainerAcMapODRecordIteratorAcMapODTableAcMapODTableDefinitionAcMapODTableRecordAcMapValue

ForMoreInformation

Formoreinformationaboutobjectdata,seetheUIdocumentation,AutodeskMapHelp,andtheMapSamplesfolderofObjectARXinstallations.

Pleasesendusyourcommentaboutthispage

ObjectDataSamples

Topicsinthissection

CreatinganObjectDataTableAttachingObjectDataTraversingObjectDataAddingorChangingObjectData

Pleasesendusyourcommentaboutthispage

CreatinganObjectDataTable

ThefollowingsamplecreatesanobjectdatatablecalledZoneswithtwocolumns,ResidentialandCommercial.

Tocreateanobjectdatatable

1. Includethenecessaryheaderfiles:

#include"StdAfx.h"

#include"StdArx.h"

#include<MapODColumn.h>

#include<MapArxApi.h>

#include<MapODDefinition.h>

#include<MapProj.h>

2. Createvariablesforthesession,project,objectdatacontainer,table,andcolumns.Forexample,createvariablesforatablewithtwocolumns.

AcMapSession*mapApi;

AcMapProject*pProj;

AcMapODContainer*pODCont;

AcMapODTableDefinition*pTabDef=NULL;

AcMapODColumnDefinition*pColDef1=NULL;

AcMapODColumnDefinition*pColDef2=NULL;

3. CreateanAutoCADMap3Dsessionandgetthetoplevelobjects.

mapApi=AcMapGetSession();

mapApi->GetProject(pProj);

pProj->GetODContainer(pODCont);

4. Allocatememoryfortableandcolumnobjectsbycallingthetableand

columnconstructorswiththenewoperator.

pTabDef=newAcMapODTableDefinition();

pColDef1=newAcMapODColumnDefinition();

pColDef2=newAcMapODColumnDefinition();

5. Foreachofthecolumns,setthecolumnnameanddescriptionandthetypeofdatathecolumnstores.Setthedefaultvalueforthedata.

pColDef1->SetName("Residential");

pColDef1->SetDescription("ResidentialR1-R3");

pColDef1->SetType(AcMap::kCharacter);

pColDef1->SetDefaultValue("R1");

pColDef2=newAcMapODColumnDefinition();

pColDef2->SetName("Commercial");

pColDef2->SetDescription("CommercialC1-C3");

pColDef2->SetType(AcMap::kCharacter);

pColDef2->SetDefaultValue("C1");

6. Addthecolumndefinitionstothetabledefinition.

pTabDef->AddColumn(*pColDef1);

pTabDef->AddColumn(*pColDef2);

7. Createtheobjectdatatable.Forexample,createatablecalledZonestostoreXDatausingthefollowingcode:

pODCont->CreateODTable("Zones",*pTabDef,"ZoningofKingCity",

Adesk::kTrue);

8. Releasethememoryyouallocatedforthetableandcolumnsinstep4usingthedeleteoperator.

if(pColDef2)deletepColDef2;

if(pColDef1)deletepColDef1;

if(pTabDef)deletepTabDef;

Pleasesendusyourcommentaboutthispage

AttachingObjectData

Thefollowingsampleattachesobjectdatatoselectedobjectsinadrawing.

Itcreatesarecordforeachoftheobjectsandaddsthedatafromanexistingtabletotherecords.Openratherthanattachthedrawingthatcontainstheobjects.

Toattachobjectdata

1. Includethenecessaryheaderfiles:

#include"StdAfx.h"

#include"StdArx.h"

#include<MapArxApi.h>

#include<MapProj.h>

#include<MapODRecord.h>

#include<MapODTable.h>

2. Declarevariables.

ads_namess,ename;

longsslen,sscur;

AcDbObjectIdeId;

AcMapSession*mapApi=NULL;

AcMapProject*pProj=NULL;

AcMapODContainer*pODCont=NULL;

AcMapODTable*pODTable=NULL;

3. CreateanAutoCADMap3Dsessionandgetthetoplevelobjects.

mapApi=AcMapGetSession();

mapApi->GetProject(pProj);

pProj->GetODContainer(pODCont);

4. Getthetablecontainingthedatatoattach.

pODCont->GetODTable(pODTable,"Zones");

5. UseADSfunctionstopromptusertoselecttheobjectstowhichtoattachthedata,andprocesstheselections.

acutPrintf("\nAttachdatatowhichobject(s)?");

if(acedSSGet(NULL,NULL,NULL,NULL,ss)!=RTNORM){

acutPrintf("\nNoobjectsselected.\n");

acedSSFree(ss);

return;

}

6. UseanADSfunctiontodeterminethenumberofobjectsselectedinstep5.

acedSSLength(ss,&sslen);

7. Loopthroughtheobjectsselectedinstep5,gettingtheentitynameofthenextobject,andconvertingittoanobjectID,whichyoupasstoAcMapODTable::AddRecord.Withintheforloop,youcreatetheAcMapODTableRecordusingthenewoperator,therebyallocatingmemoryforeachrecordadded.RemembertodeleteeachpointertoAcMapODTableRecordwithintheloop,asshownhere.

for(sscur=0;sscur<sslen;sscur++)

{

acedSSName(ss,sscur,ename);

acdbGetObjectId(eId,ename);

AcMapODTableRecord*pTabRec=NULL;

pTabRec=newAcMapODTableRecord();

pODTable->AddRecord(*pTabRec,eId);

acutPrintf("\nODRecordaddedtoobject.");

if(pTabRec)deletepTabRec;

}

8. DeletethememoryallocatedbycallingAcMapODContainer::GetODTableinstep4,andfreethememoryallocatedfortheselectionsetinstep5.

deletepODTable;

acedSSFree(ss);

Pleasesendusyourcommentaboutthispage

TraversingObjectData

Thefollowingsampleiteratesallofanobject'srecordsusingAcMapODContainer::GetObjectODRecordIterator.

YoucanalsoiterateonlythoserecordsthatarecontainedinaspecifiedtableusingAcMapODTable::GetObjectODRecordIterator.

Totraverserecords

1. Includethenecessaryheaderfiles:

#include"StdAfx.h"

#include"StdArx.h"

#include<MapArxApi.h>

#include<MapProj.h>

#include<MapODIterator.h>

2. Declarevariables.

intretCode=FALSE;

ads_nameename;

ads_pointspt;

AcDbObjectIdeId;

intrecQuantity=0;

AcMapSession*mapApi=NULL;

AcMapProject*pProj=NULL;

AcMapODContainer*pODCont=NULL;

AcMapODRecordIterator*pIter=NULL;

3. CreateanAutoCADMap3Dsessionandgetthetoplevelobjects.

mapApi=AcMapGetSession();

mapApi->GetProject(pProj);

pProj->GetODContainer(pODCont);

4. UseADSfunctionstopromptusertoselectanobject,andconverttheentitynameoftheselectedobjecttoanobjectIDforinitializingtheiteratorinthenextstep.

retCode=acedEntSel(NULL,ename,spt);

if(retCode!=RTNORM){

acutPrintf("\nNoobjectselected.\n");

return;}

acdbGetObjectId(eId,ename);

5. Getarecorditeratorandinitializeitforreading.

pODCont->GetObjectODRecordIterator(pIter);

pIter->Init(eId,AcMap::kOpenForRead,Adesk::kFalse);

6. Usetherecorditeratortocountrecordsattachedtotheobject.Printtheresults.

recQuantity=pIter->CountRecords();

acutPrintf("\nObjecthas%drecordsattached.",recQuantity);

7. Deletetheiteratorwhenyou'refinishedwithit.

if(pIter)deletepIter;

Pleasesendusyourcommentaboutthispage

AddingorChangingObjectData

Thestructureforcontainingdatainanobjectdatatableisatablerecord(AcMapOdTableRecordobject).

TheactualdataintherecordiscontainedininstancesoftheAcMapValueclass,onevalueforeachfield(column)intherecord.YoureadthevalueofarecordusingoneformofAcMapODTableRecord::Value,andyouaddnewdataormodifytheexistingvalue,usingtheotherform,whichisthenon-constoverrideofthefunction.

Thefollowingsampleshowshowtoaddnewdataormodifythecurrentdataintheobjectrecordsofselectedobjects.Beforeperformingthisprocedure,createatablenamedZones.Next,attachdata.Dataattachedtoselectedobjectsconsistsoftwocolumns:azoningcodecolumncalledCodeandanApprovedBycolumn.

Toaddorchangeobjectdata

1. Includethenecessaryheaderfiles:

#include"StdAfx.h"

#include"StdArx.h"

#include<MapODColumn.h>

#include<MapArxApi.h>

#include<MapODDefinition.h>

#include<MapProj.h>

#include<MapODRecord.h>

#include<MapODIterator.h>

2. Defineaconstantforinputoftherecordvaluesanddeclarevariables.

#defineUSR_STRG_LENGTH133

intretCode=FALSE;

ads_nameename;

ads_pointspt;

charzoneCode[USR_STRG_LENGTH]="";

charapproveCode[USR_STRG_LENGTH]="";

AcMapSession*mapApi=NULL;

AcMapProject*pProj=NULL;

AcMapODContainer*pODCont=NULL;

AcMapODRecordIterator*pIter=NULL;

AcDbObjectIdeId;

AcMapODTableRecordrecord;

3. CreateanAutoCADMap3Dsessionandgetthetoplevelobjects.

mapApi=AcMapGetSession();

mapApi->GetProject(pProj);

pProj->GetODContainer(pODCont);

4. UseADSfunctionstopromptusertoselectanobject,andconverttheentitynameoftheselectedobjecttoanobjectIDforinitializingtheiteratorinthenextstep.

retCode=acedEntSel(NULL,ename,spt);

if(retCode!=RTNORM){

acutPrintf("\nNoobjectselected.\n");

return;}

acdbGetObjectId(eId,ename);

5. Getarecorditeratorandinitializeitforwriting.Usingtheiteratorinaforloop,traversetherecordsoftheobjectselectedinstep4,gettingthetableassociatedwitheachrecord.

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***ODTable%s.",record.ODTableName());

6. Loopthroughthecolumnsofeachrecord,andprintthenameofthecolumn,whichinthisexampleiseitherCodeorApprovedBy.

for(inti=0;i<record.Count();i++)

{

AcMapODTableDefinitiontableDef=pTable->Definition();

AcMapODColumnDefinitionColumn;

tableDef.GetColumn(Column,i);

acutPrintf("\n%-15s",Column.Name());

7. Printthevalueatthecolumnoftherecordandgetapointer,colname,tothecolumn.

AcMapValue&val=record.Value(i);

acutPrintf("%s",((constchar*)val));

colname=Column.Name();

8. CreateanAcMapValuevariableandassignthevalueenteredbytheusertoit.Then,assigntheAcMapValuevariabletothevalueoftherecordusingtheAcMapODTableRecord::Valuefunction.Updatetherecordusingtherecorditerator.

if(!strcmp(colname,"Code")){

acedGetString(TRUE,"\nNewzoningcode:",zoneCode);

AcMapValuev=zoneCode;

record.Value(i)=v;

pIter->UpdateRecord(record);

}

9. Usingthesameparadigmasstep9,getandupdatetherecord'sApprovedbycolumn.

if(!strcmp(colname,"Approved")){

acedGetString(TRUE,"\nApprovedby:",approveCode);

AcMapValuev=approveCode;

record.Value(i)=v;

pIter->UpdateRecord(record);

}

10. Endtheforloopstartedinstep7anddeletethepointertothetablecreatedwithAcMapODContainer::GetODTable.Endtheforloopstartedinstep6anddeletetheiteratorcreatedinstep5.

}//endfor

if(pTable)deletepTable;

}//endfor

if(pIter)deletepIter;

Pleasesendusyourcommentaboutthispage

CoordinateSystems

TheAutoCADMap3Dcoordinate-systemsfunctionsmeasuregeodeticdistanceandtransformentitiestoaspecifiedcoordinatesystem.

Topicsinthissection

CoordinateSystemsDetails

Pleasesendusyourcommentaboutthispage

CoordinateSystemsDetails

Coordinate-SystemsFunctions

OtherInformationSources

CoordinateSystemsSamplesCoordinateSystemsGlobals

Coordinate-SystemsFunctions

Thefollowingcoordinate-systemsfunctionsareavailable:

Measurethegeodeticdistancebetweentwopoints-ade_projwsgeodistance()

Transformanentityfromthesourcetothedestinationcoordinatesystem-ade_projentityforward()

Transformanentityfromthedestinationtothesourcecoordinatesystem-ade_projentitybackward()

Forcoordinate-systemssource-codesamples,seeCoordinateSystemsSamples.

Backtotop

OtherInformationSources

FormoreinformationaboutcoordinatesystemsinAutoCADMap3D,chooseHelp>AutodeskMapHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>CoordinateSystems.

Foracoordinate-systemstutorialinAutoCADMap3D,chooseHelp>Tutorials>Contentstab,andthenchoose"WorkingwithCoordinateSystems".

Backtotop

CoordinateSystemsSamples

Toviewcodesamplesofcoordinate-systemsfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\CoordinateSystem.

Backtotop

CoordinateSystemsGlobals

Toviewthecoordinate-systemsglobals,clickthefollowinglinks:

ade_projwsgeodistance()GlobalFunctionade_projentityforward()GlobalFunctionade_projentitybackward()GlobalFunction

Backtotop

Pleasesendusyourcommentaboutthispage

ConvertingCoordinates

Convertingcoordinatesfromonegeo-referencedcoordinatesystemtoanother.

Topicsinthissection

ConvertingCoordinates

Pleasesendusyourcommentaboutthispage

ConvertingCoordinates

AnyCartesiancoordinatepairyouselectinageo-referencedcoordinatesystemcorrespondstoapointonthesurfaceoftheearth.Thisfactdefinesarelationbetweenthecoordinatepairsinonecoordinatesystemandthecoordinatepairsinanyother,solongasthepointinquestionactuallyexistsinbothsystems.Inotherwords,solongasthecoordinatesystemshavearegionofintersection,andthepointinquestionisinit.

Toconvertthecoordinatesofapointfromonegeo-referencedcoordinatesystemtoanother

1. Definea"source"coordinatesystemwithade_projsetsrc.

2. Definea"destination"coordinatesystemwithade_projsetdest.

3. Passacoordinatepairtoade_projptforward.Thefunctionassumesthatthecoordinatepairyoupasstoitisapointinthesourcesystem,anditreturnsthecorrespondingcoordinatepairinthedestinationsystem.Ifthereisnocorrespondingcoordinatepair,itreturnsnil.

Toconvertintheotherdirection,useade_projptbackward.

Youcanspecifycoordinatetriplets,butifyoudo,theZvalueisignored.

ThefollowingsampleconvertsaknownpositionfromLatitudeLongitude(LL)toUniversalTransverseMercator(UTM)usingade_projptforward().Iftheconversionissuccessful,informationabouttheconversionisdisplayedandtheUTMcoordinateisconvertedbacktoLatLongusingade_projptbackward().Ifyoudon'tknowthespecificcoordinatesystemcode,clickSelectCoordinateSystem.IntheSelectGlobalCoordinateSystemdialogbox,whichislocatedundertheMap->Tools->AssignGlobalCoordinateSystemmenuoption.Selectacategory,andthenselectfromalistofavailablecoordinatesystems.ClickPropertiestoviewtheCodevalueoftheselectedcoordinatesystem.

char*pszSourceCoordSys="LL84";

intresultCode=ade_projsetsrc(pszSourceCoordSys);

char*pszDestCoordSys="UTM27-15";

resultCode=ade_projsetdest(pszDestCoordSys);

ads_pointcoordPairToConvert;

coordPairToConvert[0]=-90.4794;

coordPairToConvert[1]=38.7503;

ads_pointconvertedCoordPair;

resultCode=ade_projptforward(

coordPairToConvert,

convertedCoordPair);

if(RTNORM==resultCode){

acutPrintf(

"\nThe%scoordinatevalueof:%.4lf\,%.4lfwassuccessfullyconverted"

"to%syieldingthevalueof:%.4lf\,%.4lf"

,pszSourceCoordSys,coordPairToConvert[0],coordPairToConvert[1]

,pszDestCoordSys,convertedCoordPair[0],convertedCoordPair[1]);

coordPairToConvert[0]=convertedCoordPair[0];

coordPairToConvert[1]=convertedCoordPair[1];

ads_pointconvertedBackCoordPair;

resultCode=ade_projptbackward(

coordPairToConvert,

convertedBackCoordPair);

acutPrintf(

"\n\n\nUsingade_projptbackward(),the%scoordinatevalueof:%.4lf\,%.4lfwas"

"successfullyconvertedbackto%syieldingthevalueof:%.4lf\,%.4lf"

,pszDestCoordSys,coordPairToConvert[0],coordPairToConvert[1]

,pszSourceCoordSys,convertedBackCoordPair[0],convertedBackCoordPair[1]);

}

else{

acutPrintf(

"\nNocoordinateconversiontookplace.");

}

Pleasesendusyourcommentaboutthispage

FeatureClassification

UseAutoCADMap3D'sfeature-classificationfeaturetocreatestandardobjectsindrawings.

Topicsinthissection

FeatureClassificationDetail

Pleasesendusyourcommentaboutthispage

FeatureClassificationDetail

Eachstandardobject,calledafeature,hasasetofuser-definedpropertiesanddata,calledafeatureclass.Allfeatureclassdefinitionsarestoredinafeature-definitionfile,orschema.Aftersettingupfeatureclassdefinitions,youcanusethemtocreateobjectswithastandardsetofpropertiesanddata.Youcanchangepropertyvalues,orthepropertiesthemselves,programmatically.Anorganizationthatcreatesroadmaps,forexample,mighthavestandardPrimaryRoadandSecondaryRoadpolylineobjectsinwhichthePrimaryRoadfeaturesarecreatedwiththicklineweightonthePrimaryRoadslayer,andSecondaryRoadfeaturesappearwiththinlineweightontheSecondaryRoadslayer.Eachroadfeaturehasassociatedobjectdata,suchasspeedlimit,numberoflanes,andsurfacetype.SeealsoOtherInformationSources.

CreatingandManagingSchemas

CreatingandManagingFeatureClassDefinitions

ClassifyingEntities

ManagingAttributesofFeatureClassDefinitions

ManagingProperties

UsingReactorswithFeatureClassDefinitionEvents

HandlingErrors

OtherInformationSources

FeatureClassificationSamples

FeatureClassificationClassesandNamespaces

CreatingandManagingSchemas

BeforeyoucanCreatingandManagingFeatureClassDefinitions,youmust

createaschemaandattachittothecurrentdrawingbyusingAcMapClassificationManagerfunctions.However,beforeyoucreateanewfeature-definitionfilewithCreateFeatureDefinitionFile(),useCanCurrentUserAlterSchema()tocheckwhetherthecurrentuserhassufficientprivilegestocreateorchangeaschema.(Eventhoughyoudon'tcheckthisfirst,CreateFeatureDefinitionFile()willcatchaninsufficient-privilegeserror.)

Alternatively,ratherthancreatinganewschema,usethecurrentlyattachedschema,indicatedbyGetFeatureDefinitionFileAttached(),orattachanexistingschemawithAttachFeatureDefinitionFile().YoucandetachaschemaexplicitlywithDetachCurrentFeatureDefinitionFile().

Aftercreatingormodifyingafeatureclassdefinitioninaschema,savethefilewithSaveCurrentFeatureDefinitionFile()orsaveacopywithSaveCurrentFeatureDefinitionFileAs().YoualsocanrefreshthecurrentschemawithReloadCurrentFeatureDefinitionFile(),butdoingsoisriskybecauseitmightreloadoutdateddata,dependingontheuser'sactions.

Forfeature-classificationsource-codesamples,seeFeatureClassificationSamples.

//Createsanewfeature-definitionfile.

AcMapObjClass::EErrCodeerrCode;

constchar*pszSchemaFileName="mySchema.xml";

//Checkwhethercurrentusercancreateorchangeschema.

if(CanCurrentUserAlterSchema())

{

//Createtheschemafile.

errCode=CreateFeatureDefinitionFile(pszSchemaFileName);

//Handleerrors.

switch(errCode)

{

caseAcMapObjClass::eNoUserPrivilegeToAlterSchema:

//Insufficient-privilegeserror.

break;

caseAcMapObjClass::eFileAlreadyExists:

//Schemafilealreadyexists(andwillbeattached).

break;

caseAcMapObjClass::eFileNameInvalid:

//Invalidfilename.

break;

caseAcMapObjClass::eFailed:

//Failedforsomeotherreason.

break;

default:

break;

}

//Attachtheschemafile.

errCode=AttachFeatureDefinitionFile(pszSchemaFileName);

if(errCode==AcMapObjClass::eOk)

{

...

}

}

Backtotop

CreatingandManagingFeatureClassDefinitions

Afteryouattachafeature-definitionfiletothecurrentdrawing,youcandefinefeatureclassesbyusingAcMapClassificationManagerfunctions.

It'sprudenttorunafewsafetychecksbeforeyoucreateafeatureclassdefinition.Forexample,youcoulddothefollowing:

UseGetFeatureClassDefinitionCount()toindicatewhetheranyexistingfeatureclassesaredefinedinthecurrentschemaanduseGetFeatureClassNames()tolisttheirnames.

UseIsFeatureClassDefinitionPresent()todeterminewhetheraspecificclassdefinitionexists.

CreateafeatureclassdefinitionbyusingCreateFeatureClassDefinition()(twoforms).Alternatively,youcanuseDuplicateFeatureClassDefinition()tocopyanexistingfeatureclassdefinitionandthenchangeitsattributesbyusingGetFeatureClassDefinition().

Aftercreatingormodifyingafeatureclassdefinitioninaschema,saveyourchangeswithSaveCurrentFeatureDefinitionFile()orSaveCurrentFeatureDefinitionFileAs().

Torenameordeleteafeatureclassdefinition,useRenameFeatureClassDefinition()orDeleteFeatureClassDefinition().

Forfeature-classificationsource-codesamples,seeFeatureClassificationSamples.

Backtotop

ClassifyingEntities

Afteryoucreatefeatureclassdefinitions,youcanusethemtoclassifytheentitiesinthecurrentdrawingbyusingAcMapClassificationManagerfunctions.

Useanyofthefollowingmethodstocheckentities:

Toavoidredoingoroverwritingpreviousclassifications,checkwhichentitiesalreadyareclassifiedandwithwhichfeatureclassdefinitions.GetClassifiedEntities()(twoforms)listsallclassifiedentitiesinthecurrentdrawing,andGetUnclassifiedEntities()liststheunclassifiedones.

UseGetUndefinedEntities()tolistentitiesthatareclassifiedbutwhosefeatureclassdefinitionsarenotintheattachedfeature-definitionfile.

UseIsClassified()todeterminewhetheraspecificentityisclassified.

Useanyofthefollowingmethodstomanageclassifiedentities:

Toclassifyoneormoreentities,useClassify()(twoforms).

Toinspectanentity'sproperties,useGetProperties()(twoforms).

Todeterminehowanentityshouldbeclassified(orreclassified),useGetClassifiedProperties()(twoforms).

Tofixout-of-rangeormissingvaluesofclassifiedproperties,useAudit()(twoforms).

Ifanentitywasclassifiedmultipletimesbyusingdifferentfeature-definitionfiles,useGetAllTags()toretrievealltheentity'sfeatureclassnamesandcorrespondingfeature-definitionfiles.

Tounclassifyoneormoreentities,useUnclassify()(twoforms)orClearAllTags()(twoforms).

Forfeature-classificationsource-codesamples,seeFeatureClassificationSamples.

Backtotop

ManagingAttributesofFeatureClassDefinitions

UseAcMapObjClassDefinitionfunctionstomanagetheattributesofafeatureclassdefinitionstoredinthefeature-definitionfileattachedtothecurrentdrawing.Youcanretrieveand(insomecases)setthefollowingattributes:

Name-GetName()/SetName()

Description-GetDescription()/SetDescription()

Icon-GetIconName()/SetIconName()

Visibility-IsVisibleInWorkspace()/SetVisibleInWorkspace()

Featuredefinitionfile-GetFeatureDefinitionFile()

Supportedentitytypes-GetSupportedEntityTypes()(twoforms)

//Printthenameofthisfeatureclassdefinitionandthe

//pathnameofthefeature-definitionfilethatitbelongsto.

constchar*pszFeatureClassDefinitionName=GetName();

constchar*pszFeatureDefinitionFile=GetFeatureDefinitionFile();

acutPrintf("\nThefeatureclassdefinitionnameis%s",pszFeatureClassDefinitionName);

acutPrintf("\nThefeature-definitionfilepathnameis%s",pszFeatureDefinitionFile);

Usethefollowingfunctionstodeterminewhereaspecificfeatureclassexistsinthefeature-classhierarchy:GetDirectBaseClassName(),IsBaseClassOf(),IsBaseClassOnly(),IsDerivedClassOf()andIsDirectBaseClassOf().

//Determinewhetherthisfeatureclassdefinitionisabaseclass

//ofthefeatureclass"Parcels".

AcMapObjClass::EErrCodeerrCode;

boolbBaseClassOf;//Output.

errCode=IsBaseClassOf(&bBaseClassOf,"Parcels");

if(errCode==AcMapObjClass::eOk)

{

if(bBaseClassOf==true)

{

...

}

}

UseGetProperty()orGetProperties()toretrieveaspecificproperty,orallproperties,ofafeatureclassdefinition.GetProperties()retrievesonlypropertiesthatareclassified,whichyoucandeterminewithIsPropertyClassified().YoucanaddordeleteapropertywithAddProperty()orDeleteProperty().Tochangeaproperty'sattributes,seeManagingProperties.

//RetrievetheLinetypeproperty.

AcMapObjClass::EErrCodeerrCode;

AcMapObjClassProperty*pProperty=NULL;

AcMapStringArrayaStrParentToSubCategoryNames;

aStrParentToSubCategoryNames.Append("General");

constchar*pszPropertyName="Linetype";

errCode=GetProperty(pProperty,aStrParentToSubCategoryNames,pszPropertyName);

if(errCode==AcMapObjClass::eOk)

{

//Processtheproperty.

}

Fordigitizingdata,useSetCreateMethod()(twoforms),GetCreateMethod(),andGetCreateMethodName()tosetorretrievetheAutoCADentitytypethatafeatureclassdefinitionuseswhenadigitizeprocessruns.

Forfeature-classificationsource-codesamples,seeFeatureClassificationSamples.

Backtotop

ManagingProperties

UseAcMapObjClassPropertyfunctionstomanageapropertyforafeatureclassdefinition.Youcanretrieveand(insomecases)setthefollowingattributesofaproperty:

Name-GetName()

Directcategory-GetCategory()

Type-GetType()

Defaultvalue-GetDefaultValue()/SetDefaultValue

Range-GetRange()/SetRange()/IsInRange()

Visibility-IsVisible()/SetVisible()

Read-only-IsReadOnly()/SetReadOnly()

Stringrepresentation-FromString()/ToString()

Forfeature-classificationsource-codesamples,seeFeatureClassificationSamples.

//SettherangeoftheLengthproperty.

AcMapObjClass::EErrCodeerrCode;

AcMapObjClassProperty*pProperty=NULL;

AcMapStringArrayaStrParentToSubCategoryNames;

aStrParentToSubCategoryNames.Append("Geometry");

constchar*pszPropertyName="Length";

errCode=GetProperty(pProperty,aStrParentToSubCategoryNames,pszPropertyName);

if(errCode==AcMapObjClass::eOk)

{

errCode=pProperty->SetRange("0.0,1.0,2.0,3.0");

if(errCode==AcMapObjClass::eOk)

{

...

}

}

Backtotop

UsingReactorswithFeatureClassDefinitionEvents

TheAcMapObjClassReactorclassprovidescallbackfunctionsthatnotifyanapplicationimmediatelyoffeatureclassdefinitionevents.Youusethismechanismtomonitororcontrolfeatureclassdefinitionoperationsbyregisteringreactorinstances.Functionsareinvokedautomaticallydependingontheoperation'stype,asdescribedinthefollowingtable:

Function InvokedwhenaFeatureClassDefinitionCreated() Featureclass

definitioniscreated

FeatureClassDefinitionDeleted() Featureclassdefinitionisdeleted

FeatureClassDefinitionModified() Featureclassdefinitionismodified

FeatureClassDefinitionRenamed() Featureclassdefinitionisrenamed

FeatureDefinitionFileAttached() Feature-definitionfileisattachedtoordetachedfromthecurrentdrawing

FeatureDefinitionFileModified() Feature-definitionfileismodifiedandsaved

UseAcMapObjClassSystemtoregisterandunregisterclassificationreactorswithAddObjClassReactor()andRemoveObjClassReactor().Touseareactor,performthefollowingsteps,asshowninthesamplecodethatfollows:

1. DeriveacustomclassfromAcMapObjClassReactor.

2. Implementeventsbyoverridingthevirtualfunctionsthatyouneed.

3. Createaninstanceofthecustomreactor.

4. Registertheinstancesothatitbecomesactive.

5. Writesomeclassificationreactorcode.

6. Removethereactorfromthelistanddeleteit.

Forfeature-classificationsource-codesamples,seeFeatureClassificationSamples.

//DeriveacustomclassfromAcMapObjClassReactor.

classAcMapObjClassMyReactor:publicAcMapObjClassReactor

{

//Overridevirtualfunctionsforthedesiredevents.

};

//Createaninstanceofthecustomreactor.

AcMapObjClassMyReactor*pMyReactor=newAcMapObjClassMyReactor;

//Registerthecustomreactor.

AcMapObjClassSystem().AddObjClassReactor(pMyReactor);

//Insertclassificationreactorcodehere.

//Removethereactoranddeleteit.

AcMapObjClassSystem().RemoveObjClassReactor(pMyReactor);

deletepMyReactor;

Backtotop

HandlingErrors

Manyfunctionsinthevariousfeature-classificationclassesreturnanAcMapObjClass::EErrCodeerrorcode.Whenaparticularfunctionreturnsanerrorcode,readthatfunction'sdocumentationforfunction-specificerrorconditionsratherthanrelyingononlythegenericerrordescriptionsintheAcMapObjClass::EErrCodedocumentation.

OtherInformationSources

FormoreinformationaboutfeatureclassificationinAutoCADMap3D,chooseHelp>AutoCADMap3DHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>FeatureClassification.

Forafeature-classificationtutorialinAutoCADMap3D,chooseHelp>Tutorials>Contentstab,andthenchoose"UsingFeatureClassification".

Backtotop

FeatureClassificationSamples

Toviewcodesamplesofclassificationfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\Classification.

Backtotop

FeatureClassificationClassesandNamespaces

Toviewthefeature-classificationclassesandnamespaces,clickthefollowing

links:

AcMapClassificationManagerClass

AcMapObjClassNamespace

AcMapObjClassDefinitionClass

AcMapObjClassPropertyClass

AcMapObjClassReactorClass

AcMapObjClassSystemClass

Backtotop

Pleasesendusyourcommentaboutthispage

ObjectFilters

TheAutoCADMap3Dobject-filtersfeaturefiltersobjects(entities)inthecurrentdrawingbasedonthespecifiedfilteringcriteria.

Topicsinthissection

ObjectFiltersDetail

Pleasesendusyourcommentaboutthispage

ObjectFiltersDetail

ObjectFilters

TheAcDbObjectFilterclassisthebaseclassforcreatingobjectfilters,andprovidesthefollowingfunctions:

Constructor/destructor-AcDbObjectFilter()/~AcDbObjectFilter()

Filterobjects-FilterObjects()

Activateobjectfilter-IsActive()/SetActive()

Forobject-filterssource-codesamples,seeObjectFiltersSamples.

BasicFilters

TheAcDbBasicFilterclass(derivedfromTheAcDbObjectFilter)filtersobjectsinthecurrentdrawingbasedonlayer,feature-class,andblockcriteria,andprovidesthefollowingfunctions:

Constructor/destructor-AcDbBasicFilter()(twoforms)/~AcDbBasicFilter()

Filterobjects-FilterObjects()

Layerfilters:

Retrievelayers-Layers()

Setlayers-SetLayers()(twoforms)

Addlayers-AddLayers()

Clearslayers-ResetLayers()

Layerstatus-LayerStatusMask()/SetLayerStatusMask().SeealsoELayerStatusenum.

Feature-classfilters:

Retrievefeatureclasses-FeatureClasses()

Setfeatureclasses-SetFeatureClasses()(twoforms)

Addfeatureclasses-AddFeatureClasses()

Clearsfeatureclasses-ResetFeatureClasses()

Blockfilters:

Retrieveblocks-Blocks()

Setblocks-SetBlocks()(twoforms)

Addblocks-AddBlocks()

Clearsblocks-ResetBlocks()

Forobject-filterssource-codesamples,seeObjectFiltersSamples.

Backtotop

UsingMultipleFilters

TheAcDbObjectFilterGroupclass(derivedfromTheAcDbObjectFilter)filtersobjectsinthecurrentdrawingbasedthebasedonthecriteriaofoneormorelistedfilters,andprovidesthefollowingfunctions:

Constructor/destructor-AcDbObjectFilterGroup()/~AcDbObjectFilterGroup()

Addfilter-AddObjectFilter()

Insertfilter-InsertObjectFilter()

Removefilter-RemoveObjectFilter()/RemoveAllObjectFilter()

Countfilters-ObjectFilterCount()

Emptytest-IsEmpty()

Retrievefilter-GetObjectFilter()

Filterobjects-FilterObjects()

Forobject-filterssource-codesamples,seeObjectFiltersSamples.

OtherInformationSources

FormoreinformationaboutobjectfiltersinAutoCADMap3D,chooseHelp>AutodeskMapHelp>Indextab,andthentypethekeywordsfiltersandqueriestodisplaytherelatedtopics.

ObjectFiltersSamples

Toviewcodesamplesofobject-filtersfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\ObjectFilter.

ObjectFiltersClasses

Toviewtheobject-filtersclasses,clickthefollowinglinks:

AcDbObjectFilterClassAcDbBasicFilterClassAcDbObjectFilterGroupClass

Pleasesendusyourcommentaboutthispage

Import-Export

UseAutoCADMap3D'simport-exportfeaturetoexchangedatainindustry-standardGISandmappingformats.

Topicsinthissection

Import-ExportDetail

Pleasesendusyourcommentaboutthispage

Import-ExportDetail

Byimportingamap,youcancombinedatafromothermappingorGISprogramsbyimportingthedataintoAutoCADMap3D.Youcanimportthemapobjectsthemselves,andthedataanddisplayoptionsassociatedwiththem.Inaddition,youcanspecifyanimportareatodeterminewhichareaofthemapwillbeimported,assignincomingobjectstoexistingfeatureclasses,andautomaticallyperformacoordinateconversionontheobjectsastheyareimported.

Byexportingamap,youcanexportdatatoanexternalfileformat.Youcanexportthemapobjectsthemselves,andthedataassociatedwiththem,andspecifythatAutoCADMap3Dperformsacoordinateconversionontheobjectsautomaticallyastheyareexported.

Useprofilestosaveyourimportandexportsettingsinaprofiletoautomatetheprocessofimportingandexportingfiles.Youcansaveandloadimportprofilefiles(.ipf)orexportprofilefiles(.epf).

Thefollowingfileformatsaresupportedforbothimportandexport,unlessotherwiseindicated:

ArcViewShapeFile(alsocalledESRIShapeFileorESRIShape)

ArcInfoCoveragesandE00

GML(GeographyMarkupLanguage)version2

GML(GeographyMarkupLanguage)version2,OrdinanceSurveyofGreatBritainMasterMap(importonly)

MapInfoMIF/MID

MapInfoTAB

MicroStationDGNversions7and8

SDTS(SpatialDataTransferStandard)(importonly)

VML(VectorMarkupLanguage)(exportonly)

VPF(VectorProductFormat)(importonly)

SeealsoOtherInformationSources.

ImportingMapsSettingImportOptionsExportingMapsSettingExportOptionsUsingReactorswithExportandImportEventsUsingIteratorsHandlingErrorsOtherInformationSourcesImport-ExportSamplesImport-ExportClasses,Namespaces,andGlobals

ImportingMaps

ToimportanfiletoanAutoCADMap3Ddrawing,performthefollowingsteps,asshowninthesamplecodethatfollows:

1. RetrievetheAutodeskMapimporterobject,anAcMapIEImportersingletoninstance,bycallingtheglobalfunctionAcMapImporter().

2. InitializetheimporterwithInit().(YoumustcallInit()beforeyoucallanyotherAcMapIEImporterfunctions.)Init()requiresanAcMapIEFormatnamethatspecifiestheformatoftheincomingfile.

3. Optionally,addreactorstotheimporter.

4. Settheimportoptions.-or-UseLoadIPF()toloadpreviouslysavedimportsettingsfromaprofile(.ipf)file.(YoucansavethecurrentimportoptionsinaprofilefilewithSaveIPF().)

5. CallImport()toperformtheimport.ImportresultsarestoredinanAcMapIE::CImportResultsstruct.

Forimport-exportsource-codesamples,seeImport-ExportSamples.

AcMapIE::ErrCodeerrCode;

//RetrievetheAutoCADMap3Dimporterobject.

AcMapIEImporter*pImporter=AcMapImporter();

//Initializetheimporter.

char*pszFormat="MIF";//NameofanAcMapIEFormat.

char*pszImpFileName="C:\\temp\\my_import_file.mif";

errCode=pImporter->Init(pszFormat,pszImpFileName);

if(errCode!=AcMapIE::kErr_OK)

{

//Handletheerror.

}

//Getaniteratoroverthelayersintheimportedfile.

AcMapIEInputLayerIterator*pInputLayers;

errCode=pImporter->InputLayerIterator(pInputLayers);

if(errCode!=AcMapIE::kErr_OK)

{

//Handletheerror.

}

//Iterateovereachlayer.

for(pInputLayers->Rewind();!pInputLayers->Done();pInputLayers->Step())

{

AcMapIEInputLayer*pLayer=NULL;

if(pInputLayers->Get(pLayer)==false)

{

//Handletheerror.

}

//Importattributedatafromtheimportfiletothe

//newobject-datatableintheAutocadMapdrawing.

//Insertcodetosetthetabletypeandtablename

//withAcMapIEInputLayer::SetDataMapping()

//andsetthefeatureclassname

//withAcMapIEInputLayer::SetFeatureClassName().

//Setcolumnmappings.

AcMapIEColumnIterator*pColumns=pLayer->ColumnIterator();

if(pColumns)

{

for(pColumns->Rewind();!pColumns->Done();pColumns->Step())

{

//Insertcodetosetcolumndatamappings

//withAcMapIEColumn::SetColumnDataMapping()

//andsetcolumnfeature-classmappings

//withAcMapIEColumn::SetColumnClassMapping().

}

deletepColumns;

}

deletepLayer;

}

deletepInputLayers;

//Performtheimportandgettheresults.

AcMapIE::CImportResultsresults;

boolbUseProgressDialog=false;

errCode=pImporter->Import(results,bUseProgressDialog);

if(errCode!=AcMapIE::kErr_OK)

{

//Handletheerror.

}

//Processorlogtheimportresults,ifdesired.

Backtotop

SettingImportOptions

WhenimportingadrawingintoAutoCADMap3D,youcansetimportoptionsforeachincominglayer.AcMapIEImporter::InputLayerIterator()retrievesaniteratoroverallimportedlayers;eachlayerisanAcMapIEInputLayerinstance,namedName().UsethefollowingAcMapIEInputLayerfunctionstosetandretrievelayer-levelimportoptions:

Data-mappingtabletypeandname-DataMapping()/SetDataMapping().SeealsoAcMapIE::ImportDataMappingenum.

Featureclass-FeatureClassName()/SetFeatureClassName()

Import-layerswitch-ImportFromInputLayerOn()/SetImportFromInputLayerOn()

Layername-LayerName()/SetLayerName().SeealsoAcMapIE::LayerNameTypeenum.

Point-importmode-PointToBlockMapping()/SetPointToBlockMapping().SeealsoAcMapIE::PointMappingTypeenum.

Targetcoordinatesystem-TargetCoordSys()/SetTargetCoordSys().SeealsoOriginalCoordSys().

Import-attributesswitch-UseForBlockAttributes()/SetUseForBlockAttributes()

Uniquekeysforimportedobjects-UseUniqueKeyField()/SetUseUniqueKeyField()

Oneachlayer,youcansetindividualmappingsfromeachincomingcolumntoatargetcolumninAutoCADMap3D.AcMapIEInputLayer::ColumnIterator()retrievesaniteratoroveralayer'scolumns;eachcolumnisanAcMapIEColumninstance,namedColumnName().Youcandefinetwotypesofcolumnmappings,providedthatyoualreadyhavesetthecolumn'sdatatableandfeatureclasswithAcMapIEInputLayer::SetDataMapping()and

AcMapIEInputLayer::SetFeatureClassName():

Datamapping-ColumnDataMapping()/SetColumnDataMapping().

Feature-classmapping-ColumnClassMapping()/SetColumnClassMapping().Feature-classmappingsarenotsetbydefaultforanycolumn.

YoualsocanusethefollowingAcMapIEImporterfunctionstosetandretrievehigh-levelimportoptions:

Auditclassifiedproperties-AuditClassifiedAfterImport()/SetAuditClassifiedAfterImport()

Driveroptions-DriverOptions()/SetDriverOptions()/InvokeDriverOptionsDialog()

Importpolygonsasclosedpolylines-ImportPolygonsAsClosedPolylines()/SetImportPolygonsAsClosedPolylines()

Location-windowfilter-LocationWindowAndOptions()/SetLocationWindowAndOptions().SeealsoAcMapIE::LocationOptionenum.

Reactors-AddReactor()/RemoveReactor();seeUsingReactorswithExportandImportEvents

Forimport-exportsource-codesamples,seeImport-ExportSamples.

Backtotop

ExportingMaps

ToexportanAutoCADMap3Ddrawing,performthefollowingsteps,asshowninthesamplecodethatfollows:

1. RetrievetheAutodeskMapexporterobject,anAcMapIEExportersingletoninstance,bycallingtheglobalfunctionAcMapExporter().

2. InitializetheexporterwithInit().(YoumustcallInit()beforeyoucallanyotherAcMapIEExporterfunctions.)Init()requiresanAcMapIEFormatnamethatspecifiesthetargetfileformat.YoucanuseFormatName()toretrievetheformatnameatany

timeafterinitialization.

3. Optionally,addreactorstotheexporter.

4. Settheexportoptions.-or-UseLoadEPF()toloadpreviouslysavedexportsettingsfromaprofile(.epf)file.(YoucansavethecurrentexportoptionsinaprofilefilewithSaveEPF().)

5. CallExport()toperformtheexport.ExportresultsarestoredinanAcMapIE::CExportResultsstruct.

Forimport-exportsource-codesamples,seeImport-ExportSamples.

AcMapIE::ErrCodeerrCode;

//RetrievetheAutoCADMap3Dexporterobject.

AcMapIEExporter*pExporter=AcMapExporter();

//Initializetheexporter.

char*pszFormat="MIF";//NameofanAcMapIEFormat.

char*pszExpFileName="C:\\temp\\my_export_file.mif";

errCode=pExporter->Init(pszFormat,pszExpFileName);

if(errCode!=AcMapIE::kErr_OK)

{

//Handletheerror.

}

//Insertcodetosetfilter,datamapping,

//andother<ahref="#export_options">exportoptions</a>.

//Performtheexportandgettheresults.

AcMapIE::CExportResultsresults;

boolbUseProgressDialog=false;

errCode=pExporter->Export(results,bUseProgressDialog);

if(errCode!=AcMapIE::kErr_OK)

{

//Handletheerror.

}

//Processorlogtheexportresults,ifdesired.

Backtotop

SettingExportOptions

Useexportoptionstocontrolwhichobjectsinthecurrentdrawingareexportedbyapplyingalayerfilter,feature-classfilter,andselectionset.(CountObjects()

countsthenumberandtypeofentitiestoexport.)Youalsocansetstorageoptions,driveroptions,datamappings,andotheroptions.UsethefollowingAcMapIEExporterfunctionstosetandretrieveexportoptions:

Discretizationangle-DiscretizationAngle()/SetDiscretizationAngle()

Driveroptions-DriverOptions()/SetDriverOptions()/InvokeDriverOptionsDialog()

Exportclosedpolylinesaspolygons-ClosedPolylinesAsPolygons()/SetClosedPolylinesAsPolygons()

Featureclassestoexport-FeatureClassFilter()/SetFeatureClassFilter()

Layerstoexport-LayerFilter()/SetLayerFilter()

MappinglayerstoDGNlevels-LayerLevelMapping()/SetLayerLevelMapping()

Polygontopology-ExportFromPolygonTopology()/SetExportFromPolygonTopology()

Selectionset-SelectionSet()/SetSelectionSet()andExportAll()/SetExportAll()

Source-columnandoutput-columndatamappings-ExportDataMappings()/SetExportDataMappings()

Storageoptions-StorageOpts()/SetStorageOpts().SeealsoAcMapIE::StorageTypeenumandAcMapIE::GeometryTypeenum.

Targetcoordinatesystem-TargetCoordSys()/SetTargetCoordSys()

Uniquekeysforexportedobjects-UseUniqueKeyField()/SetUseUniqueKeyField()

Reactors-AddReactor()/RemoveReactor();seeUsingReactorswithExportandImportEvents

Forimport-exportsource-codesamples,seeImport-ExportSamples.

Backtotop

UsingReactorswithExportandImportEvents

TheAcMapIEExportReactorandAcMapIEImportReactorreactorclassesprovidecallbackfunctionsthatnotifyanapplicationimmediatelyofexportandimportevents.Youcanusethesemechanismstomonitororcontrolexportandimportoperationsbyaddingreactorinstances.Functionsareinvokedautomaticallydependingonthestageoftheoperation,asdescribedinthefollowingtables:

Exportreactorfunction InvokedRecordError() Ifanerroroccurs

duringexportRecordExported() Afteranentityis

exportedRecordReadyForExport() Beforeanentityis

exported

Importreactorfunction InvokedRecordError() Ifanerroroccurs

duringimportRecordImported() Afteranentityis

importedRecordReadyForImport() Beforeanentityis

imported

YoucanaddorremoveexportreactorswithAcMapIEExporter::AddReactor()orAcMapIEExporter::RemoveReactor(),andaddorremoveimportreactorswithAcMapIEImporter::AddReactor()orAcMapIEImporter::RemoveReactor().Touseareactor,performthefollowingsteps,asshowninthesamplecodethatfollows:

1. DeriveacustomclassfromAcMapIEExportReactororAcMapIEImportReactor.

2. Implementeventsbyoverridingthevirtualfunctionsthatyouneed.

3. Createaninstanceofthecustomreactor.

4. Addtheinstancesothatitbecomesactive.

5. Writesomeexportorimportreactorcode.

6. Removethereactoranddeleteit.

Forimport-exportsource-codesamples,seeImport-ExportSamples.

//DeriveacustomclassfromAcMapIEExportReactor.

classAcMapIEMyExportReactor:publicAcMapIEExportReactor

{

//Overridevirtualfunctionsforthedesiredexportevents.

};

//Createaninstanceofthecustomreactor.

AcMapIEMyExportReactor*pMyReactor=newAcMapIEMyExportReactor;

//Addthecustomreactor.

AcMapIEExporter().AddReactor(pMyReactor);

//Insertexportreactorcodehere.

//Removethereactoranddeleteit.

AcMapIEExporter().RemoveReactor(pMyReactor);

deletepMyReactor;

Backtotop

UsingIterators

Thefollowingtableliststheiteratorclasses,whichprovideiteratorsovercollectionsofobjectsthatimport-exportfunctionsreturnortake.TheAcMapIEExpressionTargetIteratorandAcMapIENameValueIteratorclassesallowyoutomodifytheiterator'sunderlyingcollectionbyadding,updating,anddeletingelements,whereastheotherclassesiterateoverfixedcollections.TheglobalfunctionsAcMapExportFormatIterator()andAcMapImportFormatIterator()returntheexport-formatandimport-formatiterators,respectively.

Class Iteratesoveracollectionof

AcMapIEColumnIterator AcMapIEColumninstances

AcMapIEExpressionTargetIterator Expression-targetpairsAcMapIEFormatIterator AcMapIEFormat

instancesAcMapIEInputLayerIterator AcMapIEInputLayer

instances

AcMapIENameValueIterator Name-valuepairs

Forimport-exportsource-codesamples,seeImport-ExportSamples.

Backtotop

HandlingErrors

Manyfunctionsinthevariousimport-exportclassesreturnanAcMapIE::ErrCodeerrorcode.Whenaparticularfunctionreturnsanerrorcode,readthatfunction'sdocumentationforfunction-specificerrorconditionsratherthanrelyingononlythegenericerrordescriptionsintheAcMapIE::ErrCodedocumentation.

Backtotop

OtherInformationSources

FormoreinformationaboutimportingandexportingmapsinAutoCADMap3D,chooseHelp&gt;AutoCADMap3DHelp&gt;Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)&gt;ImportingandExportingMaps.

Foranimport-exporttutorialinAutoCADMap3D,chooseHelp&gt;Tutorials&gt;Contentstab,andthenchoose"ImportingandExportingData".

Backtotop

Import-ExportSamples

Toviewcodesamplesofimport-exportfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\ImportExport.

Backtotop

Import-ExportClasses,Namespaces,andGlobals

Toviewtheimport-exportclasses,namespaces,andglobals,clickthefollowinglinks:

OracleSpatialData

ThistopicdescribesthelatestimplementationoftheOracleSpatialAPI.

Topicsinthissection

OracleSpatialDataDetail

Pleasesendusyourcommentaboutthispage

OracleSpatialDataDetail

ClassnamesinthisAPIbeginwith"AcMapOSE".UseitforallnewdevelopmentthatinvolvesOracleSpatialaccess,orconsiderusingtheFDOEnablerAPI,astilllaterimplementation,whichprovidesaccesstoOracleSpatialdatabasesandotherdatabaseformatsaswell.

AlthoughtheearlierimplementationoftheOracleSpatialAPIremainsinplace,andexistingcodethatisbasedonitisstillvalid,itisdeprecated.ClassnamesintheearlierOracleSpatialAPIbeginwith"AcMapOracle".TheAcMapOracleclassesaredescribedintheAutoCADMap3DObjectARXReference,buttheyarenotdiscussedintheDeveloper'sGuide.

ManagingtheconnectionManagingreactorsExportingdata

Queryingandimportingdata

OracleandAutoCADIDs

GettingcorrespondingIDs

Gettingotherinformation

Filteringobjects

Errorprocessing

Otherinformationsources

Codesamples

Classes

Managingtheconnection

Beforeyoucandoanythingelse,youmustgettheAcMapOSEConnectionobject.

SolongasAutoCADMap3Disrunning,thereisalwaysanAcMapOSEConnectionobject,evenifnoconnectioniscurrentlyineffect.TheobjectisinstantiatedautomaticallywhenanAutoCADMap3Dsessionopens,andisdestroyedautomaticallywhenthesessioncloses.

BecausetheAcMapOSEConnectionobjectisuniquewithinasession,therecanneverbemorethanoneconnectionineffectatatime.Toconnect,disconnect,orchangethecurrentconnection,youmodifythisuniqueobject.Youcanmodifyit(orassessitsstate)eitherthroughthetheUIortheAPI.It'sthesameobjecteitherway.

AcMapOSEConnectionclass

AcMapOSEGetConnectionglobalfunction

ConnectingtoanOracleSpatialDatabase

Managingreactors

Inadditiontofunctionsformodifyingorassessingitsstate,theAcMapOSEConnectionobjecthasfunctionsformanagingreactors.Forexample,tomonitorandreacttoconnectionevents,subclassacustomreactorfromAcMapOSEConnectionReactor,andthenaddaninstanceofittoyourapplicationusingAcMapOSEConnection::AddConnectionReactor().Similarly,youcancreateandaddreactorsforimportandexportevents.

AcMapOSEConnectionclass

AcMapOSEConnectionReactorclass

AcMapOSEExportReactorclass

AcMapOSEImportReactorclass

ConnectingtoanOracleDatabase(sample)

Exportingdata

ToaddnewrecordstotheOracledatabase,ortoupdaterecordsthatwereimportedandtheneditedbyadding,changing,ordeletingdata,useanAcMapOSEExportobject.Tosetexportoptionsandspecifywhichfeatureswill

beexported,useAcMapOSEExport::Init().

NotethatanAcMapOSEExportobjecthastwofunctionsforexporting.ExportObjects()exportsobjectslistedinanAcDbObjectIdArray.ExportObjectsAll()exportsallobjectsinthedrawingdatabase.BothfunctionsexportonlyfeaturesspecifiedinthevFeaturesNamesargumentofAcMapOSEExport::Init(),andbothfunctionsaresubjecttoexportoptionsspecifiedbythenOptionsargumentofAcMapOSEExport::Init().OptionvaluesaredefinedintheAcMapOSEExport::EExportOptionsenumeration.

Tomonitorandreacttoexportevents,useacustomsubclassofAcMapOSEExportReactor.

Notethat,forthesakeofperformance,theexportoperationdoesnotprocessasetofobjectsonebyone.Rather,itcollectstheobjectswiththeirassociateddatainacacheandthenbulk-processesthem.ThecomplementofAcMapOSEExportReactorfunctionsreflectsthistwo-stepprocess.

AcMapOSEExportclass

AcMapOSEExport::EExportOptionsenumeration

AcMapOSEExportReactorclass

ExportingtoanOracleSpatialDatabase

Queryingandimportingdata

ToimportobjectsfromanOracledatabasetoaprojectdrawing,firstuseanAcMapOSEQueryobjecttospecifyconditionsfortheobjectstoimport,andthenuseanAcMapOSEImportobjectfortheimportitself.

YoucaninitializetheAcMapOSEQueryobjectwith

Thecurrentimportquery,asdefinedintheImportdialogboxintheuserinterface.Toseethisdialog,usetheMAPOSEREADcommand.

AnimportqueryloadedfromtheOracledatabaseaftersavingonetherepreviously.

Anexplicitsetofconditions.

AfterinitializingtheAcMapOSEQueryobject,youcanconvertitsquerytoSQLformatforviewingpurposes.

Tomonitorandreacttoimportevents,useacustomsubclassofAcMapOSEImportReactor.

AcMapOSEQueryclass

AcMapOSEImportclass

AcMapOSEImportReactorclass

ImportingfromanOracleSpatialDatabase

OracleandAutoCADIDs

InOracledatabases,entitieshaveOracleIDs(OValue).InAutoCADdatabases,theyhaveAutoCADIDs(AcDbObjectId).WhendrawingobjectsareimportedfromanOracledatabasetoaprojectdrawing(AcMapProjectobject),AutoCADMap3DassignsthemAutoCADIDs,butkeepstracktheircorrespondingOracleIDs.Notehowever,thatthisinformationisdiscardedwithoutsavingwhenthedrawingcloses,whichmeansthattheentireprocessofupdatingasetofOraclerecords—importing,editing,exporting—mustrunfromstarttofinishonacontinuouslyopendrawing.

ForinformationaboutgettingcorrespondingIDs,click<imgheight="12"width="12"border="0"src="graphics/chiclet.gif">.

GettingcorrespondingIDs

IfyouhaveimportedasetofrecordsfromanOracledatabase,andyouneedtoknowexplicitlywhichrecordisassociatedwithagivendrawingobject(entity),orwhichentitywithagivenrecord,youcanuseanAcMapOSEObjectobjecttofindout.Afterintializingsuchanobjectwithanentity'sAutoCADID,youcangetitsOracleID,andvice-versa,providedthatthedrawinghasremainedopensincetheentitywasimported.Ifthedrawinghasnotremainedopen,importedentitieslosetheirimportedstatus,inwhichcase,insteadoftheAcMapOSEObjectobjectgivingyouanOracleIDinexchangeforanentity'sAutoCADID,itgivesyou0(aninvalidkeyvalue),asitdoesforanyentitythatisnotanimportedone.

ForinformationaboutOracleandAutoCADIDs,click<imgheight="12"

width="12"border="0"src="graphics/chiclet.gif">.

Gettingotherinformation

YoucanuseAcMapOSEObjectfunctionstogetotherinformationaboutaqueriedobjectbesidesitsAutoCADorOracleID.Forexample,itsEditSetstatus,inorout.

AcMapOSEObjectclass

GettingCorrespondingIDs

Filteringobjects

Tofilternewobjectsfromasetofdrawingobjects,useAcMapOSEProject::FilterNewObjects().Inaddition,youcanconstraintheresultbyfeatureoredit-setstatus(inorout).

Likewise,tofilterqueriedobjects,useAcMapOSEProject::FilterQueriedObjects().Inaddition,youcanconstraintheresultbyfeatureoredit-setstatus(inorout).Queriedobjectsaredeliveredinthreesubsetsbyeditstatus:erased,modified,andunchanged.

AcMapOSEProjectclass

FilteringObjects

Errorprocessing

WhenanAutoCADMap3Doperationfails,theerrormessageanderrorcodearepushedtotheerrorstack(AcMapErrorStack).Intheeventofanerror,checkthestacktodiscoverwhatwentwrongandtakeappropriateaction.

Otherinformationsources

FormoreinformationaboutAutoCADMap3DandOracleSpatialdata,referto

UserInterfaceHelpforthePolygonandAdvancedOracleExtensiontoAutoCADMap3D—IntheAutodeskMapapplication,clickthequestionmarkiconinthePolygonAndAdvancedOracleExtensiontoolbar.

Codesamples

Toviewcodesamples,clicklinksbelow.

ConnectingtoanOracleSpatialDatabase

ExportingtoanOracleSpatialDatabase

ImportingfromanOracleSpatialDatabase

SubclassingCustomReactors

GettingCorrespondingIDs

FilteringObjects

ThefollowingtopicsdescribesampleObjectARXprojects.TheprojectfoldersareunderMapSamples\OracleSpatialinyourAutoCADMap3DObjectARXinstallation.

StoringBlockAttributePositionsinanOracleSpatialDatabase

StoringBlockDefinitionsinanOracleSpatialDatabase

ImportingFromanOracleSpatialDatabase

NoteThesampleprojectsthatarelocatedinMapSamples\OraclearefortheearlierOracleSpatialimplementation,whichisstillsupported,butisnowdeprecated.

Classes

ToviewOracleSpatialdataclasses,clicklinksbelow.

AcMapOSEConnection

AcMapOSEConnectionReactor

AcMapOSEExport

AcMapOSEExportReactor

AcMapOSEImport

AcMapOSEImportReactor

OracleSpatialSamples

TheOracleSpatialsamples.

ConnectingtoanOracleSpatialDatabaseSubclassingCustomReactorsExportingtoanOracleSpatialDatabaseImportingFromanOracleSpatialDatabaseGettingCorrespondingIDsFilteringObjects

Topicsinthissection

ConnectingtoanOracleSpatialDatabaseSubclassingCustomReactorsExportingtoanOracleSpatialDatabaseImportingfromanOracleSpatialDatabaseGettingCorrespondingIDsFilteringObjects

Pleasesendusyourcommentaboutthispage

ConnectingtoanOracleSpatialDatabase

ThefollowingcodesampleillustratesconnectingtoanOracledatabaseandaddingcustomreactors.

CustomreactordeclarationsareinMyMapOracleReactors.h,oneofthefilesincludedatthebeginningofthesample.The"SubclassingCustomReactors"sampleshowswhatsuchafilewouldcontain.

ManagingtheConnection(Overview)SubclassingCustomReactors(Sample)OtherRelatedSamples

#include"StdAfx.h"

#include"StdArx.h"

#include"AdMapOracleConnection.h"

#include"MyMapOracleReactors.h"//Customreactors

BOOLConnectToOracle()

{

//Getconnectionpointer

AcMapOSEConnection*pConnection=AcMapOSEGetConnection();

//Initializereactors

MyConnectionReactor*pConnectReactor=newMyConnectionReactor();

MyExportReactor*pExportReactor=newMyExportReactor();

MyImportReactor*pImportReactor=newMyImportReactor();

//Addreactorstoconnectionobject

pConnection->AddConnectionReactor(pConnectReactor);

pConnection->AddExportReactor(pExportReactor);

pConnection->AddImportReactor(pImportReactor);

//Maketheconnection

BOOLbConnect=FALSE;

if(!pConnection->IsConnected())

{

bConnect=pConnection->Connect("Scott","TestDB","Scott","Tiger",false);

}

else

{

acutPrintf("AlreadyconnectedtoOracle!");

returnFALSE;

}

//Checkforvalidconnectionusingvariousdiagnosticfunctions

//Checkifschemaisvalid()

if(pConnection->IsSchemaValid())

{

acutPrintf("\nSchemaisvalidforthisconnection\n");

}

else

{

acutPrintf("\nSchemaisnotvalid\n");

}

//GetthelateststateoftheOracledatabaseifithasbeen

//changedsincetheconnectionwasmade

if(pConnection->RefreshSchema())

{

acutPrintf("\nSchemarefreshed\n");

}

else

{

acutPrintf("\nErrorrefreshingschema\n"):

}

//Getalistofthefeaturenamesinthecurrentschema

std::vector<std::string>vFeatureNames;

if(pConnection->Features(vFeatureNames))

{

acutPrintf("\nGotfeaturenames\n");

}

else

{

acutPrintf("\nErrorgettingfeaturenames\n");

}

//Gettheservicename

char*pService=0;

pSerive=newchar[80];

strcpy(pService,pConnection->Service());

acutPritnf("\nServiceis%s\n",pService);

delete[]pService;

//Gettheschemaname

char*pSchema=0;

pschema=newchar[80];

strcpy(pSchema,pConnection->Schema());

acutPritnf("\nSchemais%s\n",pSchema);

delete[]pSchema;

//Gettheusername

char*pUserName=0;

pUserName=newchar[80];

strcpy(pUserName,pConnection->UserName());

acutPritnf("\nUserNameis%s\n",pUserName);

delete[]pUserName;

//Breaktheconnection

if(pConnection->Disconnect())

acutPritnf("\nDisconnectedfromOracle\n");

else

acutPritnf("\nErrordisconnectingfromOracle\n");

//Removereactorsfromconnectioninterface

pConnection->RemoveConnectionReactor(pConnectReactor);

pConnection->RemoveExportReactor(pExportReactor);

pConnection->RemoveImportReactor(pImportReactor);

deletepConnectReactor

deletepExportReactor

deletepImportReactor

}

Pleasesendusyourcommentaboutthispage

SubclassingCustomReactors

ThefollowingsamplecodeillustratessubclassingcustomreactorsfromAcMapOSE[xx]Reactorclasses.

Classesandfunctionsaredeclared,butfunctiondefinitions,whichwouldbehighlyimplementationspecific,arenotshown.ThisisanexampleofwhatMyMapOracleReactors.h,oneoftheincludefilesinthe"ConnectingtoanOracleDatabase"sample,wouldcontain.

Managingreactors

ConnectingtoanOracleSpatialDatabase

Codesamples

#include"AdMapOracleReactor.h"

classMyConnectionReactor:publicAcMapOSEConnectionReactor

{

public:

MyConnectionReactor();

virtual~MyConnectionReactor();

virtualvoidConnected();

virtualvoidDisconnected();

virtualvoidBeforeConnect();

virtualvoidBeforeDisconnect();

};

classMyExportReactor:publicAcMapOSEExportReactor

{

public:

MyExportReactor();

virtual~MyExportReactor();

virtualvoidBeforeObjectCached(AcDbEntity*);

virtualvoidObjectCached(AcDbEntity*,OValue);

virtualvoidObjectRejected(AcDbEntity*);

virtualvoidBeforeObjectsExported(std::vector<OValue>&);

virtualvoidObjectsExported(std::vector<OValue>&);

};

classMyImportReactor:publicAcMapOSEImportReactor

{

public:

MyImportReactor();

virtual~MyImportReactor();

virtualvoidBeforeRecordImport(constODynaset&);

virtualvoidRecordImported(constODynaset&,AcDbEntity*);

virtualvoidRecordRejected(constODynaset&);

};

Pleasesendusyourcommentaboutthispage

ExportingtoanOracleSpatialDatabase

ThefollowingcodesampleillustratesexportingspatialdatafromaprojectdrawingtoanOracledatabase.

Note Thesampleassumesanopenprojectdrawingcontainingsomeobjects.Italsoassumesthattheconnectionobjectisactuallyconnectedtoadatabase.Click"ConnectingtoanOracleDatabase"forsamplecode.

ConnectingtoanOracleSpatialDatabase(Sample)ExportingData(Overview)RelatedSamples

#include"StdAfx.h"

#include"StdArx.h"

#include"AdMapOracleConnection.h"

#include"AdMapOracleExport.h"

BOOLExportToOracle()

{

//Getconnectionpointer

AcMapOSEConnection*pConnection=AcMapOracleGetConnection();

//Declareexportinterface

AcMapOSEExport*pExport=newAcMapOSEExport(pConnection);

//Note:Beforecallingexportfunctions,initializethe

//exportinterfacetospecifyexportoptionsandwhich

//featurestoexport

//ExportOption1-Exportonlynewobjectsanderase

//exportedobjectsfromthedrawing

//Emptyfeaturevectormeansexportallfeaturesinthe

//drawingdatabasewhenyoucallexportfunctions

std::vector<std::string>vFeatureNames;

//Initialize

if(pExport->Init(vFeatureNames,kRemoveExported))

{

acutPrintf("\nInit()successful\n");

//Export

AcDbDatabase*pDwg;

//Getavaliddrawingdatabasereferencefor*pDwg

//...(addcodehere)

if(pExport->ExportObjectsAll(pDwg))

{

acutPrintf("\nExportsuccessful\n");

}

else

{

acutPrintf("\nExportfailed\n");

}

}

else

{

acutPrintf("\nExport->Init()failed\n");

}

//ExportOption2-Exportselectedfeatures,update

//modifiedobjectsinOracle,anddeleteerasedobjects

//fromOracle

vFeatureNames.push_back("Feature1");

vFeatureNames.push_back("Feature2");

//Initialize

if(pExport->Init(vFeatureNames,

AcMapOSEExport::kUpdateModified|

AcMapOSEExport::kUpdateErased|

AcMapOSEExport::kRemoveExported))

{

acutPrintf("\nInit()successful\n");

//Export

if(pExport->ExportObjectsAll(pDwg))

{

acutPrintf("\nExportsuccessful\n");

}

else

{

acutPrintf("\nExportfailed\n");

}

}

else

{

acutPrintf("\nExport->Init()failed\n");

}

//ExportOption3-Exportaspecificsetofobjects

//Initialize-seeinitializingcodesamplesabove

//Export

AcDbObjectIdArrayidArray;

//PopulateidArraywithasetofobjectstoexportby

//manuallyselectingoriteratingthroughthedrawing

//database

//...(addcodetopopulateidArray)

if(pExport->ExportObjects(idArray);

{

acutPrintf("\nExportsuccessful\n");

}

else

{

acutPrintf("\nExportfailed\n");

}

deletepExport;

}

Pleasesendusyourcommentaboutthispage

ImportingfromanOracleSpatialDatabase

ThefollowingsampleillustratesimportingspatialdatafromanOracledatabasetoaprojectdrawing.

Thesampleisintwoparts.First,itdefinesaquerytospecifyaconditionfortheobjectstoimport,andthenitimportsthem.

Note Thesampleassumesthatthereisanopenprojectdrawing,andthatanimportqueryhasbeendefinedalreadythroughtheImportdialogboxintheUI(usetheMAPOSEREADcommand).Italsoassumesthattheconnectionobjectisactuallyconnectedtoadatabase.Click"ConnectingtoanOracleDatabase"forsamplecode.

ConnectingtoanOracleSpatialDatabase

Queryingandimportingdata

Codesamples

#include"StdAfx.h"

#include"StdArx.h"

#include"AdMapOracleConnection.h"

#include"AdMapOracleQuery.h"

#include"AdMapOracleImport.h"

BOOLImportFromOracle()

{

//DefineQuery

//Getconnectionpointer

AcMapOSEConnection*pConnection=AcMapOSEGetConnection();

//Declarequeryinterface

AcmapOSEQuery*pQuery=newAcMapOSEQuery(pConnection);

//Initializequeryinterfacewiththecurrentimportquery

//(definedthroughtheuserinterface)ofanopenproject

//drawing;inthiscase,thecurrentprojectdrawing

pQuery->InitWithCurrent(

acdbHostApplicationServices()->workingDatabase());

//OrinitializewithaNULLdatabase,whichhasthesame

//effectasthepreviouscall

pQuery->InitWithCurrent();

//Orinitializewithspecificcondition(s)

//Emptyvectoroffeaturesmeansqueryallfeaturesinthe

//Oracledatabase

std::vector<std::string>vFeatureNames;

pQuery->AddWhereConditionInFeatures(

vFeatureNames,

"AdMapEntityTypeISNOTNULL");

//YoucanclearthequerywithpQuery->Clear(),

//butnotrightnow;westillneedit

//CheckthequerywithConvertToSql()

char*psql=pQuery->ConvertToSql();

//SavethequerytotheOracledatabase

pQuery->Save("MyQuery");

//Loadthesavedqueryintoanotherqueryobject

AcMapOSEQuery*pNewQuery=newAcMapOSEQuery(pConnection);

pNewQuery->Load("MyQuery");

//Compareoldandnewqueries

char*pNewSql=pNewQuery->ConvertToSql();

if(strcmp(pSql,pNewSql)==0)

acutPrintf("QueryLoad/Saveworks!\n");

else

acutPrintf("QueryLoad/Savefailed!\n");

//ImportData

AcMapOSEImport*pImport=newAcMapOSEImport(pConnection);

//Usequerydefinedabovetoimportdata

if(pImport->Import(pQuery))

acutPrintf("\nImportsuccessful\n");

else

acutPrintf("\nImportfailed\n");

deletepQuery;

deletepImport;

}

Pleasesendusyourcommentaboutthispage

GettingCorrespondingIDs

Thefollowingsampledemonstratesgettinganentity'sOracleIDifitsAutoCADIDisknown,andviceversa.

ItalsodemonstratesthatroundtripswithcorrespondingIDsarereliable—thatifyouuseanAutoCADIDtogetanOracleID,andthenusetheOracleIDtogetanAutoCADID,thetwoAutoCADIDsarethesame.

Note Thesampleassumesanopenprojectdrawingcontainingimportedentities.Italsoassumesthattheconnectionobjectisactuallyconnectedtoadatabase.Click"ConnectingtoanOracleDatabase"forsamplecode.

ConnectingtoanOracleSpatialDatabaseOracleandAutoCADIDsGettingcorrespondingIDsCodesamples

#include"StdAfx.h"

#include"StdArx.h"

#include"AdMapOracleConnection.h"

#include"AdMapOracleIdentification.h"

BOOLIdentification()

{

//Getconnectionpointer

AcMapOSEConnection*pConnection=AcMapOSEGetConnection();

//Declareidentificationobject

AcMapOSEObject*pId=newAcMapOSEObject(pConnection);

AcDbObjectIdAcadId;

AcDbEntity*pEntity;

ads_nameen;

ads_pointpt;

OValueOracleID;

charpBuf[100];

//Getadrawingobject(entity)fromtheuser

if(acedEntSel("\nSelectanentity:",en,pt)==RTNORM)

{

//Gettheentity'sAutoCADID

acdbGetObjectId(AcadId,en);

//Gettheentity'shandleandprintittotheAutoCADMap3Dtextwindow

if(Acad::eOk==acdbOpenAcDbEntity(pEntity,AcadId,AcDb::kForRead))

{

AcadId.handle().getIntoAsciiBuffer(pBuf);

acutPrintf("\nAcadhandlesel:%s",pBuf);

pEntity->close();

}

//InitializeidentificationobjectwithAutoCADID

bInit=pId->Init(AcadId);

//Gettheentity'scorrespondingOracleID

OracleID=pId->GetOracleID();

//Againinitializeidentificationobject,nowwithOracleID

bInit=pId->Init(OracleID);

//Gettheentity'scorrespondingAutoCADID

AcadId=pId->GetAcadID();

//Gettheentity'shandleandprintittotheAutoCADMap3Dtextwindow,

//andnotethatitisthesameentityasbefore

if(Acad::eOk==AcDbOpenAcDbEntity(pEntity,AcadId,AcDb::kForRead))

{

AcadId.handle().getIntoAsciiBuffer(pBuf);

acutPrintf("\nAcadhandlesel:%s",pBuf);

pEntity->close();

}

//YoucangetotherinformationaboutthisentitybesidesitsIDs

//FeatureName()

char*pName;

strcpy(pName,pId->FeatureName());

acutPrintf("\nFeatureName=%s\n",pName);

//IsInEditSet()

if(pId->IsInEditSet())

{

acutPrintf("\nObjectislocked\n");

}

else

{

acutPrintf("\nObjectisnotlocked\n");

}

//IsModified()

if(pId->IsModified())

{

acutPrintf("\nObjecthasbeenmodified\n");

}

else

{

acutPrintf("\nObjecthasnotbeenmodified\n");

}

//IsErased()

if(pId->IsErased())

{

acutPrintf("\nObjecthasbeenerased\n");

}

else

{

acutPrintf("\nObjecthasnotbeenerased\n");

}

//AddToEditSet()

if(pId->AddToEditSet())

{

acutPrintf("\nObjectaddedtoEditSet\n");

}

else

{

acutPrintf("\nObjectnotaddedtoEditSet\n");

}

//RemoveFromEditSet()

if(pId->removeFromEditSet())

{

acutPrintf("\nObjectremovedfromEditSet\n");

}

else

{

acutPrintf("\nObjectsnotremovedfromEditSet\n");

}

//Version()

unsignedlongulVersion;

ulVeresion=pId->Version();

//IsUpToDate()

if(pId->IsUpToDate())

{

acutPrintf("\nObjectisuptodate\n");

}

else

{

acutPrintf("\nObjecthasbeenmodifiedsinceimportingit\n");

}

//WhoHasIt()

unsignedlongulUserId;

std::stringstrNtuser,strDbUser,strMapUser,strComputer,strLoginTime;

if(pId->WhoHasIt(

ulUserId,

strNtUser,

strDbUser,

strMapUser,

strComputer,

strLoginTime))

{

acutPrintf("\nUserId=%ul\n",ulUserId);

acutPrintf("\nNtUser=%s\n",strNtUser.data());

acutPrintf("\nDbuser=%s\n",strDbUser.data());

acutPrintf("\nMapUser=%s\n",strMapUser.data());

acutPrintf("\nComputer=%s\n",strcomputerr.data());

acutPrintf("\nLoginTime=%s\n",strComputer.data());

}

else

{

acutPrintf("\nObjectisnotlocked\n");

}

}//if(acedEntSel("\nSelectanentity:",en,pt)==RTNORM)

acadSSFree(en);

deletepId;

}

Pleasesendusyourcommentaboutthispage

FilteringObjects

Thefollowingcodesampleillustratesfilteringqueriedandnewdrawingobjects,andaddingandremovingobjectsfromtheEditSet.

Filteringobjects

Codesamples

#include"StdAfx.h"

#include"StdArx.h"

#include"AdMapOracleConnection.h"

#include"AdMaporacleProject.h"

BOOLFilterProjectObjects()

{

//Getconnectionpointer

AcMapOSEConnection*pConnection=AcMapOSEGetConnection();

//Declareprojectinterface

AcMapOSEProject*pProject=newAcMapOSEProject(pConnection);

//Initializeprojectinterfacewithadrawingdatabase

if(pProject->Init(

acdbHostApplicationServices()->workingDatabase()))

{

acutPrintf("\nProjectinterfaceinitialized\n");

}

else

{

acutPrintf("\nErrorinitializingprojectinterface\n");

}

//Filterqueriedobjects

//Emptyvectoroffeaturesmeansfilterallfeaturesin

//thedrawingdatabase

std:vector<std:string>vFeatureNames;

//SimilarlyemptyinputarrayofobjectIdsmeansfilter

//allobjectsinthedrawingdatabase

AcDbObjectIdArrayarrInput,arrErased;

AcDbObjectIdArrayarrModified,arrUnchanged,arrFilteredOut;

if(pProject->FilterQueriedObjects(

vFeatureNames,

arrInput,

arrErased,

arrModified,

arrUnchanged,

arrFilteredOut,

AcMapOSEProject::kInEditSet|AcMapOSEProject::kNotInEditSet))

{

acutPrintf("\nInputarray=%d\n",arrInput.length());

acutPrintf("\nErasedarray=%d\n",arrErased.length());

acutPrintf("\nModifiedarray=%d\n",arrModified.length());

acutPrintf("\nUnchangedarray=%d\n",arrUnchanged.length());

acutPrintf("\nFilterarray=%d\n",arrFilteredOut.length());

}else{

acutPrintf("\nFilterQueriedObjects()returnedfalse\n");

}

//Filternewobjects

//Filterthesefeatures

vFeatureNames.push_back("Feature1");

vFeatureNames.push_back("Feature2");

//EmptyinputarrayofobjectIdsmeansfilterallobjects

//inthedrawingdatabase

AcDbObjectIdArrayarrInput,arrNew,arrFilteredOut;

if(pProject->FilterNewObjects(

vFeatureNames,

arrInput,

arrNew,

arrFilteredOut,

AcMapOSEProject::kInEditSet|AcMapOSEProject::kNotInEditSet))

{

acutPrintf("\nInputarray=%d\n",arrInput.length());

acutPrintf("\nNewarray=%d\n",arrErased.length());

acutPrintf("\nFilterarray=%d\n",arrFilteredOut.length());

}else{

acutPrintf("\nFilterNewObjects()returnedfalse\n");

}

//AddobjectstoEditSet

//PopulatearrAcadIdswithdrawingobjectsbymanually

//selectingoriteratingthroughdrawingdatabase;

//arrFilteredOutreportsobjectsthatcouldnotbe

//addedtotheEditSet

AcDbObjectIdArrayarrAcadIds,arrFilteredOut;

//...(addcodetopopulatearrAcadIds)

if(pProject->AddToEditSet(arrAcadIds,arrFilteredOut))

{

acutPrintf("\nObjectsaddedtoEditSet\n");

}

else

{

acutPrintf("\nErroraddingobjectstoEditSet\n");

}

//RemoveobjectsfromEditSet

//PopulatearrAcadIdswithdrawingobjectsbymanually

//selectingoriteratingthroughdrawingdatabase;

//arrFilteredOutreportsobjectsthatcouldnotbe

//removedfromtheEditSet

AcDbObjectIdArrayarrAcadIds,arrFilteredOut;

//...(addcodetopopulatearrAcadIds)

if(pProject->RemoveFromEditSet(arrAcadIds,arrFilteredOut))

{

acutPrintf("\nObjectsremovedfromEditSet\n");

}

else

{

acutPrintf("\nErrorremovingobjectsfromEditSet\n");

}

deletepProject;

}

Pleasesendusyourcommentaboutthispage

OracleSpatialSampleProjects

TheOracleSpatialsampleprojects.

ImportingFromanOracleSpatialDatabaseStoringBlockDefinitionsinanOracleSpatialDatabaseStoringBlockAttributePositionsinanOracleSpatialDatabase

TheprojectfoldersareintheMapSamples\OracleSpatialfolderinAutoCADMap3DObjectARXinstallations.

NoteThesampleprojectsthatareinMapSamples\OraclearefortheearlierOracleSpatialimplementation,whichisstillsupported,butisnowdeprecated.

Topicsinthissection

ImportingFromanOracleSpatialDatabaseStoringBlockDefinitionsinanOracleSpatialDatabaseStoringBlockAttributePositionsinanOracleSpatialDatabase

Pleasesendusyourcommentaboutthispage

ImportingFromanOracleSpatialDatabase

OracleSpatialData(Overview)RelatedSamples

The"ImportingFromanOracleSpatialDatabase"sampleisanObjectARXprojectlocatedintheMapSamples\AcMapFlatOrclQueryfolderinAutoCADMap3DObjectARXinstallations.

CommandsImplemented

Theprojectcreatesanrxmodulewhichexposesthefollowingcommands.

ORAAPICONNECT—forconnectingtotheOracledatabase.

ORAAPIIMPORT—forreviewing,composing,orrunningqueries

ORAAPIDISCONNECT—fordisconnecting.

Importdialogbox

TheORAAPIIMPORTcommandopenstheImportdialogbox,whichincludesthefollowingelements,amongothers.

ConditionSamples—AlistofconditionsreadfromSqlWhereClauses.txtonthelocalmachine.Clickaconditiontovieworchangeit.

Connect—ClicktoconnecttotheOracledatabaseifnotconnectedalready.

Features—Whenconnected,alistoffeaturesinthecurrentschema.ClickafeatureandthenclickGetAliasestodisplayalistofaliasesandcorrespondingnamesforthefeature'stables.See"TableAliases"below.

Tablealiases

Tocomposeaconditionforagivenfeature,youhavetospecifywhichtabletouseifthefeaturehasmorethanone,andyouhavetorefertothistablebyitsalias.Ifthereisonlyonetable,itsaliasis"Table0"andspecifyingitisoptional.Thefollowingconditionusesatablealias.

Select*

FromRIVERSTable0

WhereTable.DEPTH>5;

Togettablealiaseswhenthereismorethanonetableforafeature,clickGetAliasesintheImportdialog.

Columntypes

Towriteacondition,youmayneedthetypeofagivencolumn.Togetcolumntypes,clickDescribeTableintheImportdialogboxtogetinformationaboutanytableinthecurrentschema.

Tocreateaquery

1. SelectoneormorefeaturesintheFeatureslistbox.

2. TypeaWHEREclauseintheeditcontrolbelowtheConditionSampleslist.TheWHEREclauseisappliedtoeachoftheselectedfeaturesasitistyped,withoutcheckingtoseeifitisvalid.Iftheconditionisnotvalid—forexample,ifitreferencesatablethatdoesnotbelongtothefeature—thequeryfailswhenitexecutes.

3. ClickViewSqlStatementtoseethecorrespondingSQLstatement.Ifmorethanonefeatureisselected,therewillbeacorrespondingnumberofSQLstatements.

4. ClickSavetosavethequeryforfutureuse.

5. ClickImporttorunthequeryandimportobjects.

Toviewasavedquery

ClickLoad.ThisactionloadsaqueryfromthetableADMPIMPORTSETTINGSin

thecurrentschemaanddisplaysitsSQLstatementinaseparatedialogbox.Youcan'texecutethequery,butyoucanviewit,andyoucancopypartsofittouseinotherqueries.

Torunaquery

ClickImport.

Note

Keepinmindthatthepurposeofthisapplicationistoinstruct.Itlacksextensiveerrorhandling.Useitwithcaution.

Pleasesendusyourcommentaboutthispage

StoringBlockDefinitionsinanOracleSpatialDatabase

OracleSpatialData(Overview)RelatedSamples

The"StoringBlocks"sampleisanObjectARXprojectlocatedintheMapSamples\AcMapFlatOrclBlockfolderinAutoCADMap3DObjectARXinstallations.

Classeshighlighted

IthighlightsthefollowingOracleSpatialclasses.

AcMapOSEExportReactor

Thefollowingclassesareincludedalso,buttheiruseislessextensive.

AcMapOSEConnection

Commandsimplemented

Theprojectcreatesanrxmodulewhichexposesthefollowingcommands.

SAVEBLOCKTOORACLEinstallscustomexportandconnectionreactors.ThesereactorsenablestoringblockdefinitionsinanOracledatabase.

LOADBLOCKSFROMORACLEreadsblockdefinitionsfromanOracledatabaseandplacestheminthetablerecordoftheactiveprojectdrawing.Thiscommandshouldbeexecutedtosetblockdefinitionsinplacebeforeimportingblockreferences.

STOPSAVEBLOCKTOORACLEremovesthecustomreactorsthatwereaddedbySAVEBLOCKTOORACLE.

Note

Keepinmindthatthepurposeofthisapplicationistoinstruct.Useitwithcaution.Itlacksextensiveerrorhandling,anditmaybogdownwhenthedatasetislarge.

Pleasesendusyourcommentaboutthispage

StoringBlockAttributePositionsinanOracleSpatialDatabase

OracleSpatialData(Overview)RelatedSamples

The"StoringBlockAttributePositions"sampleisanObjectARXprojectlocatedinMapSamples\AcMapFlatOrclAttrPosinAutoCADMap3DObjectARXinstallations.

ClassesHighlighted

IthighlightsthefollowingOracleSpatialclasses.

AcMapOSEConnectionAcMapOSEImportReactorAcMapOSEExportReactorAcMapOSEObject

Thefollowingclassesareincludedalso,buttheiruseislessextensive.

AcMapOSEImportAcMapOSEExportAcMapOSEQueryAcMapOSEConnectionReactor

Commandsimplemented

TheprojectcreatesanrxmodulewhichletstheuserchangeattributepositionsinaprojectdrawingandpreservethesechangesinanOracledatabase.Itexposesthefollowingcommands.

APEXPORTexportstheactiveprojectdrawingtoanOracledatabase,includinginformationaboutattributepositions.

APIMPORTimportsOracleSpatialdatatotheactiveprojectdrawing,restoringattributestotheiroriginalpositions.

Note

ThesampleassumesthatfeaturesarealreadydefinedcompletelyusingourMAPOSEADMINcommand.

Keepinmindthatthepurposeofthisapplicationistoinstruct.Useitwithcaution.Itlacksextensiveerrorhandling,anditmaybogdownwhenthedatasetislarge.

Pleasesendusyourcommentaboutthispage

Topology

AnAutoCADMap3Dtopologyisasetofobjectsandtheobjectdatathatdefinestherelationshipsbetweentheobjects.

Topicsinthissection

TopologyDetail

Pleasesendusyourcommentaboutthispage

TopologyDetail

Anodetopologydefinestheinterrelationofnodes(pointobjects).Nodetopologiesoftenareusedinconjunctionwithothertopologiesinanalysis.Examplesofnodetopologiesincludestreetlights,city-maintainedtrees,ordrillholesforcoresamples.Anetworktopologyconsiderstheinterconnectionoflinks(lines)formingalinearnetwork.Linkscanconnectnodes.Examplesofnetworktopologiesincludeastreetnetworkandawater-distributionapplicationthattracestheflowofwaterfromapumpingstationtoresidences.Apolygontopologydefinespolygonsthatrepresentenclosedareassuchaslandparcelsandcensustracts.Asinglelinkdefinesthecommonboundarybetweenadjacentareas.Apolygontopologycanbeusedfortaxassessmentandlandplanninginwhichparcelsoflandarerepresentedbypolygons.Polygontopologiescanrepresentpoliticalboundaries,suchasvotingdistricts,city,state,orprovincialboundaries,specialdistricts,andschooldistricts.

Withtopologies,youcanperformspatialanalysessuchas:

Tracethroughnetworktopologies(shortest-pathtraces,best-routeanalysis,andfloodtraces)

Findtheareawithinacertaindistanceofmapfeatures(bycreatingbuffers)

Dissolveandoverlaypolygontopologies

Determineconditionsofadjacency(whatisnexttowhat),containment(whatisenclosedbywhat),andproximity(howclosesomethingistosomethingelse)

Topologyinformationisstoredasobjectdataoneachelementthatmakesupthetopology.Thisdatacanbesavedaspartofthecurrentmap,orsavedbacktoasourcedrawing.Becausetopologyisdefinableforamap,identifiersusedtostorethetopologyareuniquetothemap.Topologyineachdrawingmustbeseparateandunique.AutodeskMapdoesnotsupporttopologydatathatspansseveraldrawingfiles(suchastiledmaps)unlesstheyarecombinedinaproject.

Youmustcreatecentroidsformpolygonsandclosedpolylinesbeforebuildingatopologywiththem.

SeeCreatingCentroids.

Youmustcleandrawingobjectsbeforebuildingatopologywiththem.

SeeDrawingCleanup.

CreatingandManagingTopologies

AcMapTopologyAcMapTopologyManager

Closeatopology-Close()

Createaninstanceoftopology-AcMapTopology()

Createafullyspecifiedtopology-Create()(twoforms).SeealsoETopologyTypeenumandECreateOptionsenum.PriortocreatinganewtopologywithCreate(),callthefollowingfunctionstooverridethedefaultcentroid-,edge-,andnode-creationsettings:

SetCentroidCreationSettings().SeealsoAcMapPointCreationSettingsclass.

SetEdgeCreationSettings().SeealsoAcMapEntityCreationSettingsclass.

SetNodeCreationSettings().SeealsoAcMapPointCreationSettingsclass.

Deleteatopology-Delete()

Existencetest-TopologyExists()(twoforms).SeealsoETopologyScopeenum.

Openatopologyinthecurrentdrawing-Open().SeealsoEOpenModeenum.

Openatopologyinthecurrentandsourcedrawings-Open().SeealsoEOpenModeenumandEAuditResultsenum.

Updateatopology-Refresh()/NeedsRefresh()

Fortopologysource-codesamples,seeTopologySamples.

//Createatopologyobject,verifyit,closeit,anddestroyit.

AcMap::EErrCodeerrCode;

ETopologyTypeeType=ePoint;

constchar*pszTopologyName="MyNodeTopology";

//Forsafety,usuallyaddtheexistencetest

//if(AcMapTopologyManager::TopologyExists(pszTopologyName)){...}

//beforecreatinganewtopology.

AcMapTopology*pTopology=newAcMapTopology(pszTopologyName);

//See<ahref="#samples">TopologySamples</a>forsamplecode

//thatshowshowtopopulatethesearrays.

AcDbObjectIdArrayedgeObjIds;

AcDbObjectIdArraynodeObjIds;

AcDbObjectIdArraycentroidObjIds;

...

errCode=pTopology->Create(edgeObjIds,nodeObjIds,centroidObjIds,int(eType));

if(AcMap::kOk==errCode)

{

//Verifytheresultbyclosingandreopeningthenewlycreatedtopology.

pTopology->Close();

pTopology->Open(AcMapTopology::eForRead);

//Anothertest:Confirmthatthetopologyhasthecorrectnodes.

AcMapNodePtrArrayapNodes;

if(AcMap::kOk==pTopology->GetNodes(apNodes))

{

//Verifythenodes....

apNodes.Empty();

}

else

{

//Cannotgetnodes-handletheerror.

}

}

else

{

//Cannotcreatetopology-handletheerror.

}

//Cleanup.

pTopology->Close();

deletepTopology;

pTopology=NULL;

ManagingTopologyProperties

AcMapTopologyAcMapTopologyManagerAcMapTopologySource

Completeness-IsComplete()

Description-GetDescription()/SetDescription()

Error-markerstyles-GetMarkerStyles().SeealsoAcMapMarkerStylesclass.

Highlighting-ShowGeometry()

Loadedorunloaded-IsLoaded()

Name-GetName()/Rename()

Scope-GetTopologyScope().SeealsoETopologyScopeenum.

Source-GetTopologySource()/GetSource()

Status-GetStatus().SeealsoEStatusenum.

Type-GetType()/IsFixedType()/IsLinearType()/IsLogicalType()/IsPointType()/IsPolygonType()SeealsoETopologyTypeenum.

NoteGetTopologySource()takestopologysourceinformationasAcMapTopologySourceinstancesinthearraytypedefAcArray<AcMapTopologySource>AcMapTopologySourceArray.

Fortopologysource-codesamples,seeTopologySamples.

//Renameatopology.

AcMap::EErrCodeerrCode;

constchar*pszTopologyName="MyTopology";

constchar*pszNewTopologyName="MyRenamedTopology";

errCode=AcMapTopologyManager::Rename(pszTopologyName,pszNewTopologyName);

if(AcMap::kOk==errCode)

{

//Processtherenamedtopology.

//Perhapsinspectandchangeitsdescription.

...

}

elseif(AcMap::kErrTopInvalidName==errCode)

{

//Handlethebadtopologyname.Abadnametypicallyis

//NULL,empty,toolong,orhasnonalphabeticcharacters.

}

elseif(AcMap::kErrTopNotExist==errCode)

{

//Thegiventopologydoesn'texist.

}

else

{

//Handleadifferenttypeoferror.

}

Adding,Editing,andDeletingTopologyElements

AcMapTopologyAcMapTopoFullEdgeAcMapTopoNodeAcMapTopoPolygon

Addacurve(linearobject)-AddCurveObject()

Addapoint-AddPointObject()

Addpolygonedges-AddPolygons()

Deleteanode-DeleteNode()(twoforms)

Deleteapolygon-DeletePolygon()(twoforms)

Deleteanedge-DeleteEdge()

Mergemanyneighboringpolygons-MergePolygons()(twoforms)

Mergetwoneighboringpolygons-MergePolygons()(twoforms)

Moveanode-MoveNode()(twoforms)

Splitapolygon-SplitPolygon()(twoforms)

Fortopologysource-codesamples,seeTopologySamples.

//Moveanodeinatopology.

AcMap::EErrCodeerrCode;

constchar*pszTopologyName="MyNodeTopology";

AcMapTopology*pTopology=newAcMapTopology(pszTopologyName);

//Openthetopologyforwrite.

if(AcMap::kOk==pTopology->Open(AcMapTopology::eForWrite))

{

//Getthenodeofinterest(withobjectID=4,inthiscase)

//andmoveittoanewlocation.

AcMapTopoNode*pNode=NULL;

pTopology->GetNode(pNode,4);

AcGePoint3dnewLocation(39.0,15.0,0.0000);

if(AcMap::kOk!=pTopology->MoveNode(*pNode,newLocation))

{

//Handletheerror.

}

deletepNode;

pTopology->Close();

}

else

{

//Cannotopentopology-handletheerror.

}

QueryingTopologies

AcMapTopologyAcMapTopoFullEdgeAcMapTopoNodeAcMapTopoPolygon

Specificedge-FindEdge()

Edgenearestapoint-FindEdge()

Edge,node,orpolygonnearestapoint-FindTopologyObject().SeealsoAcMapTopoElementclass.

Nodenearestapoint-FindNode()

Polygoncontainingapoint-FindPolygon()

Polygonsneighboringacurve-FindNeighborPolygons().Seealso

ArraysofTopologyElements.

Fortopologysource-codesamples,seeTopologySamples.

//Findapolygoninatopology.

AcMap::EErrCodeerrCode;

constchar*pszTopologyName="MyPolygonTopology";

AcMapTopology*pTopology=newAcMapTopology(pszTopologyName);

//Openthetopologyfromthesourcedrawingforread.

if(AcMap::kOk==pTopology->Open(AcMapTopology::eForRead,true,false,NULL))

{

//Findthepolygoncontainingaspecificpoint.

AcMapTopoPolygon*pPolygon;

AcGePoint3dpoint(30.0,12.0,0.0000);

errCode=pTopology->FindPolygon(pPolygon,point);

if(AcMap::kOk==errCode)

{

//Isthisapolygonofinterest(withobjectID=184,inthiscase)?

if(pPolygon->GetID()==184)

{

//Processthepolygon.

}

}

else

{

//FindPolygon()failed-handletheerror.

}

//Cleanup.

deletepPolygon;

pPolygon=NULL;

pTopology->Close();

}

else

{

//Failedtoopentopology-handletheerror.

}

RetrievingTopologyElements

AcMapTopologyAcMapTopoFullEdgeAcMapTopoHalfEdgeAcMapTopoNodeAcMapTopoPolygon

AllAutoCADentities-GetEntityIds()

Allfulledges-GetFullEdges().SeealsoArraysofTopologyElements.

Allnodes-GetNodes().SeealsoArraysofTopologyElements.

Allpolygons-GetPolygons().SeealsoArraysofTopologyElements.

SpecificAutoCADentity-GetEntityId()

Specificfulledge-GetFullEdge()

Specifichalfedge-GetBackwardEdge()/GetForwardEdge()

Specificnode-GetNode()

Specificpolygon-GetPolygon()

Fortopologysource-codesamples,seeTopologySamples.

//Getthenodesofatopology.

AcMap::EErrCodeerrCode;

constchar*pszTopologyName="MyNodeTopology";

AcMapTopology*pTopology=newAcMapTopology(pszTopologyName);

AcMapNodePtrArrayapNodes;

//Openthetopologyforread.

if(AcMap::kOk!=pTopology->Open(AcMapTopology::eForRead,true,false,NULL))

{

//Failedtoopentopology-handletheerror.

}

if(Acad::eOk==pTopology->GetNodes(apNodes))

{

//Processeachnode.

for(inti=0;i<apNodes.length();i++)

{

//Getthenodelocation.

AcGePoint3dpoint;

errCode=apNodes[i]->GetLocation(point);

if(Acad::eOk==errCode)

{

//Processthenode.

}

}

}

else

{

//GetNodes()failed-handletheerror.

}

//Cleanup.

apNodes.Empty();

pTopology->Close();

Backtotop

ManagingTopologyElements

AcMapTopology

Fulledges-AcMapTopoFullEdgeinstances(derivedfromAcMapTopoElement)

AssociatedAutoCADentity-GetEntity()

Associatedpolygon-GetPolygon().SeealsoAcMapTopoPolygonclass.

Associatedring-GetRing().SeealsoAcMapTopoRingclass.

Associatedtopology-GetTopology().SeealsoAcMapTopologyclass.

Coincidentornearbypoint-IsOnThisObject()

Edgedirection-GetDirection()/SetDirection().SeealsoEDirectionenum.

Edgelength-GetLength()

Edgeresistance-GetResistance()/SetResistance()

Nextedge-GetNextEdge()

Nextnode-GetNextNode()

Traversinghalfedge-GetHalfEdge()

Uniqueidentifier-GetID()

Halfedges-AcMapTopoHalfEdgeinstances

Associatedpolygon-GetPolygon().SeealsoAcMapTopoPolygonclass.

Associatedring-GetRing().SeealsoAcMapTopoRingclass.

Associatedtopology-GetTopology().SeealsoAcMapTopologyclass.

Containingfulledge-GetFullEdge()

Edgeresistance-GetResistance()/SetResistance()

Nextedge-GetNextEdge()

Next/previousnode-GetNextNode()/GetPreviousNode()

Nodes-AcMapTopoNodeinstances(derivedfromAcMapTopoElement)

AssociatedAutoCADentity-GetEntity()

Associatedtopology-GetTopology().SeealsoAcMapTopologyclass.

Coincidentornearbypoint-IsOnThisObject()

Edges-GetEdges().SeealsoAcMapTopoHalfEdgeclassandArraysofTopologyElements.

Nextedge-GetNextEdge()(twoforms).SeealsoAcMapTopoFullEdgeandAcMapTopoHalfEdgeclasses.

Nodelocation-GetLocation()/SetLocation()

Nodemobility-IsMoveable()/SetIsMoveable()

Noderesistance-GetResistance()/SetResistance()

Uniqueidentifier-GetID()

Polygons-AcMapTopoPolygoninstances(derivedfromAcMapTopoElement)

AssociatedAutoCADentity-GetEntity()

Associatedtopology-GetTopology().SeealsoAcMapTopologyclass.

Coincidentornearbypoint-IsOnThisObject()

Hierarchicalparent/childrenpolygons-GetHierParent()/GetHierChildren()

Multi-polygonparent-GetParent()

Polygonarea-GetArea()

Polygonboundary-GetBoundary().SeealsoArraysofTopologyElements.

Polygoncentroid-GetCentroid()

Polygonperimeter-GetPerimeter()

Traversaltoneighboringpolygon-Traverse()

Uniqueidentifier-GetID()

Rings-AcMapTopoRinginstances

Constituentedges-GetEdges().SeealsoAcMapTopoHalfEdgeclassandArraysofTopologyElements.

Firstedge-GetStartEdge().SeealsoAcMapTopoHalfEdgeclass.

Outerpolygonboundary-IsExterior().SeealsoAcMapTopoPolygon::GetBoundary().

Ringarea-GetArea()

Ringlength-GetLength()

Fortopologysource-codesamples,seeTopologySamples.

//Getaspecificpolygonfromatopologyandprint

//statisticsforitsrings.

AcMap::EErrCodeerrCode;

char*pszTopologyName="MyTopology";

AcMapTopology*pMapTopology=NULL;

//Openthetopologyforread.

if(AcMapTopologyManager::TopologyExists(pszTopologyName))

{

pMapTopology=newAcMapTopology(pszTopologyName);

if(AcMap::kOk!=pMapTopology->Open(AcMapTopology::eForRead))

{

//Cannotopentopology-handletheerror.

}

}

//Getapolygonofinterest(withobjectID=10,inthiscase)

//andretrieveitsringswithGetBoundary().

AcMapTopoPolygon*pPolygon=NULL;

if(AcMap::kOk==pTopology->GetPolygon(pPolygon,10))

{

//Getthepolygon'srings.

AcMapRingPtrArrayapRings;

errCode=pPolygon->GetBoundary(apRings);

if(AcMap::kOk==errCode)

{

//Getstatisticsforeachring.

intnRings=apRings.length();//Numberofrings.

for(intnRingIndex=0;nRingIndex<nRings;nRingIndex++)

{

AcMapTopoRing*pRing=apRings[nRingIndex];

//Isringexteriororinterior?.

char*pszExtOrInt=pRing->IsExterior()?"exterior":"interior";

//Printtherings'areaandlength.

acutPrintf("\n#%dis%10s,Area:%-0.4lfLength:%-0.4lf",

(nRingIndex+1),pszExtOrInt,pRing->GetArea(),pRing->GetLength());

}

apRings.Empty();//Freethearrayofrings.

}

else

{

//Cannotgetthepolygon'sboundary-handletheerror.

}

}

else

{

//Cannotgetthespecifiedpolygon-handletheerror.

}

//Cleanup.

deletepPolygon;

pPolygon=NULL;

pMapTopology->Close();

Backtotop

<aid="analyzing">AnalyzingTopologies

Shortest-pathtrace-Ashortest-pathtraceusesanetworktopologytocalculatetheshortestpathbetweentwopointsordeterminetheoptimalroutebasedonvaluesofdirectionandresistance.Inastreetnetwork,forexample,youcanfindtheshortestpathbetweenafirestationandaschool.UseTraceLeastCostPath()tocalculateashortest-pathtraceandanAcMapTraceParametersinstancetosettraceparameters.

Best-routetrace-Abest-routetraceusesanetworktopologytocalculatethebestroutefromastartingpointtoanendpoint,withoneormoreintermediatepoints.AutoCADMap3Ddeterminestheoptimalroutebasedonvaluesofdirectionandresistance.Inastreetnetwork,forexample,youcanfindthebestroutetotravelwhenvisitingseveralcustomersitesfromahotel.UseTraceBestPath()tocalculateabest-routetraceandanAcMapTraceParametersinstancetosettraceparameters.

Floodtrace-Anetworkfloodtracetracesoutfromapointinalldirections,giventhepointwherethenetworkstartsandthemaximumdistancethatthenetworkcantraverse.Afloodtracedetermineshowmanylinksandnodescanbetraveledbeforetheaccumulatedresistanceexceedsthespecifiedmaximumresistance.Youcanfindallrestaurantswithina10-minutewalkofahotel,forexample,orchecktheintegrityofanetworktopology(ifsomelinksarenotflooded,thetopologyisincomplete).UseTraceFlood()tocalculateafloodtraceandanAcMapFloodParametersinstancetosettraceparameters.

Bufferingatopology-Bufferanalysis,orbuffering,identifiesobjectswithinaspecifiedoffsetofelementsinnode,network,andpolygontopologies.Abufferisazonethatisdrawnaroundatopology.Youcanspecifyabufferoneithersideofarivertoshowtheextentofafloodplain,forexample.UseBuffer()tocreateanewtopologywithabuffersetting.

Dissolvingacompositetopology-Ifatopologycontainsmanysmallerpolygons,youcancreateanewtopologybycombiningpolygonsthat

sharethesamedatavalueinaspecifiedfield,calledthedissolvefield,whichcanbeanobject-datafieldoracolumninalinkedexternaldatabase.UseDissolve()todissolveatopology.

Overlayingtopologies-Overlayanalysisletsyouoverlaytopologiesthatareloadedintothecurrentdrawing.Thethreetypesofoverlayanalysisarenodeswithpolygons,networkswithpolygons,andpolygonswithpolygons.Whenyouoverlaytwotopologies,youchoosethemethodinwhichthetwoselectedtopologiesinteract.Insomecases,theresultvariesaccordingtowhichtopologyisthesourceandwhichistheoverlay.Youhavethefollowingoverlayoptions:

Clip()-Aclipoperationusestheoverlaypolygontopologyasaboundary.Thepartsofthesourcepolygonsoutsidetheoverlaypolygonsareclippedanddiscarded.Youcanusethisoptiontoshowpolygonswithinaboundarypolygon,suchasacityorstateboundary.

Erase()-Aneraseoperationusestheoverlaypolygontopologylikeamaskanderaseseverythinginthesourcepolygontopologythatiscoveredbytheoverlaytopology.

Identity()-AnidentityoperationworkslikeUnion()onthesourcetopologyandlikeIntersect()ontheoverlaytopology.UseIdentity()tocombinenodes,links,orpolygonswithpolygonsandkeepalltheinputgeometry.Identity()createsonetopologywithonelinkwherethelinkiscrossedbytheoverlaytopology.

Intersect()-Anintersectoperationcombinestopologiesandkeepsonlythecommongeometry.Intersect()actsliketheBooleanANDoperation.Theresultsarethesamewhichevertopologyischosenasthefirstorsecond.Objectdataiscombinedforthetwooperations.

Paste()-Apasteoperationpastestheoverlaypolygontopologyontopofthesourcepolygons.Thesourcepolygonsnotcoveredbytheoverlayremain.Paste()canbeusedwithonlypolygons.

Union()-Aunionoperationcombinespolygonswithpolygonsandkeepsallgeometry.Union()actsliketheBooleanORoperationandcanbeusedwithonlypolygons.Youcancombineparcelswithsoilsinformationforpropertyassessment,forexample.UseUnion()tomaintainbothsetsofgeometrytogetherandpullthemapartasneeded.

TheoverlayfunctionsalltakesourceandoverlaydataasAcMapTopoOverlayDatainstancesinthearraytypedefAcArray<AcMapTopoOverlayData>AcMapOverlayDataArray.

NoteBeforecreatingnewtopologiesbybufferingoroverlayingexistingtopologies,youcancallSetCentroidCreationSettings(),SetEdgeCreationSettings(),andSetNodeCreationSettings()tooverridethedefaulttopology-creationvalues.

Fortopologysource-codesamples,seeTopologySamples.

//Twotopologiesareneeded:sourceandoverlay.

constchar*pszSourceTopologyName="MyNodeTopology";

AcMapTopology*pSourceTopology=newAcMapTopology(pszSourceTopologyName);

constchar*pszOverlayTopologyName="MyPolygonTopology";

AcMapTopology*pOverlayTopology=newAcMapTopology(pszOverlayTopologyName);

AcMap::EErrCodeerrCode;

//Openbothsourceandoverlaytopologiesforread.

if(AcMap::kOk==pSourceTopology->Open(AcMapTopology::eForRead))

{

if(AcMap::kOk==pOverlayTopology->Open(AcMapTopology::eForRead))

{

//Createtheintersectionofthesourceandoverlaytopologies.

errCode=pSourceTopology->Intersect(pOverlayTopology,"OutputTopo","Intersect",NULL,NULL,NULL);

if(AcMap::kOk==errCode)

{

//Processthetopologyintersection.

}

else

{

//Cannotcreatetopologyintersection-handletheerror.

}

pOverlayTopology->Close();

}

else

{

//Cannotopenoverlaytopology-handletheerror.

}

pSourceTopology->Close();

}

else

{

//Cannotopensourcetopology-handletheerror.

}

UsingIterators

AcMapTopoIteratorAcMapTopology

Countthenumberoftopologies-Count()

Last-elementflag-IsDone()

Movetofirst/nextelement-First()/Next()

Currenttopology-GetTopology()

Currenttopology'sname-GetName()

Currenttopology'sdescription-GetDescription()

Currenttopology'stype-GetType()

Fortopologysource-codesamples,seeTopologySamples.

AcMap::EErrCodeerrCode;

//Initializetheiterator.

AcMapTopoIterator*pIterator=newAcMapTopoIterator;

AcMapTopology*pTopology=NULL;

//Iteratethroughthetopologyobjects.

pIterator->First();

while(!pIterator->IsDone())

{

pIterator->GetTopology(pTopology);

//Processthetopology...

errCode=pIterator->Next();

}

deletepIterator;

deletepTopology;

//Toiteratewithafor-loop:

//for(pIterator.First();!pIterator.IsDone();pIterator.Next()){...}

ArraysofTopologyElements

AcMapTopoElementPtrArray

Arrayclass HoldspointerstoAcMapFullEdgePtrArray AcMapTopoFullEdge

instancesAcMapHalfEdgePtrArray AcMapTopoHalfEdge

instancesAcMapNodePtrArray AcMapTopoNode

instancesAcMapObjectPtrArray AcMapTopoElement

instancesAcMapPolygonPtrArray AcMapTopoPolygon

instancesAcMapRingPtrArray AcMapTopoRing

instances

Fortopologysource-codesamples,seeTopologySamples.

HandlingErrors

ManyfunctionsinthevarioustopologyclassesreturnanAcMap::EErrCodeerrorcode.Whenaparticularfunctionreturnsanerrorcode,readthatfunction'sdocumentationforfunction-specificerrorconditionsratherthanrelyingononlythegenericerrordescriptionsintheAcMap::EErrCodedocumentation.

OtherInformationSources

FormoreinformationabouttopologyinAutoCADMap3D,chooseHelp&gt;AutoCADMap3DHelp&gt;Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)&gt;Topology(SpatialAnalysis).

ForatopologytutorialinAutoCADMap3D,chooseHelp&gt;Tutorials&gt;Contentstab,andthenchoose"UsingTopologyandSpatialAnalysis".

ForinformationaboutobjectdatainAutoCADMap3D,chooseHelp&gt;AutoCADMap3DHelp&gt;Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)&gt;ObjectData.

TopologySamples

Toviewcodesamplesoftopologyfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\Topology.

TopologyClasses,Namespaces,andGlobals

Toviewthetopologyclasses,namespaces,andglobals,clickthefollowinglinks:

AcMapTopologyClass

AcMapTopoElementClass

AcMapTopoFullEdgeClass

AcMapTopoHalfEdgeClass

AcMapTopoNodeClass

AcMapTopoPolygonClass

AcMapTopoRingClass

AcMapTopoIterator

AcMapTopologySourceClass

AcMapTopoOverlayDataClass

AcMapEntityCreationSettingsClass

AcMapPointCreationSettingsClass

AcMapFloodParametersClass

AcMapTraceParametersClass

Centroids

Creatingcentroidsmovesattacheddatafromtheperimetersofmpolygonsandclosedpolylinestotheircentroidssothatthedataisnotlostwhentopologiesarecreated.

Topicsinthissection

CreatingCentroids

Pleasesendusyourcommentaboutthispage

CreatingCentroids

Youmustcreatecentroidsformpolygonsandclosedpolylinesbeforebuildingatopologywiththem.

AclosedpolylineisapolygonproducedbythePOLYGONcommand.

CreatingCentroids

OtherInformationSources

CreatingCentroidsSamplesCreatingCentroidsNamespace

CreatingCentroids

UsetheCreateCentroids()(twoforms)functionsintheAcMapUtilitiesnamespacetocreatecentroids.

Forcentroid-creationsource-codesamples,seeCreatingCentroidsSamples.

Backtotop

OtherInformationSources

FormoreinformationaboutcreatingcentroidsinAutoCADMap3D,chooseHelp&gt;AutodeskMapHelp&gt;Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)&gt;Topology(SpatialAnalysis)&gt;EditingTopologies&gt;CreatingCentroidsforPolygons.

Backtotop

CreatingCentroidsSamples

Toviewcodesamplesofcentroid-creationfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMap

Samples\CreateCentroid.

Backtotop

CreatingCentroidsNamespace

Toviewthecentroid-creationnamespace,clickthefollowinglink:

AcMapUtilitiesNamespace

Backtotop

Pleasesendusyourcommentaboutthispage

DrawingCleanup

Youmustcleandrawingobjectsbeforebuildingatopologywiththem.

Topicsinthissection

DrawingCleanupDetails

Pleasesendusyourcommentaboutthispage

DrawingCleanupDetails

Let'slookatthisintwophases,preparingthecleanupmodel,whichendswithacalltotpm_cleaninit,andexecutingthecleanup,whichbeginswithacalltotpm_cleanstart.

Topreparethecleanupmodel

1. Allocatememoryforthecleanupmodel.Usetpm_cleanalloc.

ade_idcleanupModelId=tpm_cleanalloc();

2. Allocatememoryforcleanupvariables,whichspecifypropertiesforthecleanupprocess.Thevariablesareinitializedtotheirdefaultvalues.Usetpm_varalloc.

ade_idcleanupVarId=tpm_varalloc();

Ifyouwillbespecifyinganexplicitlistofcleanupactions(youcreateandmanagethislistwithcallstotpm_cleanactionlistinsandrelatedfunctions),alsoallocatememoryforcleanupactionvariables,whichspecifypropertiesforindividualactions.Againusetpm_varalloc.

ade_idcleanupActionVarId=tpm_varalloc();

3. Getaselectionsetofobjectstobecleaned(theincludeset).

ads_namessObjsForCleanup;

acutPrintf("\nSelecttheobjectstoperformcleanupon.");

acedSSGet(NULL,NULL,NULL,NULL,ssObjsForCleanup);

Orcreateone.

structresbuf*pFilteredEntitySelectionRb=acutBuildList(

RTDXF0,"LWPOLYLINE",

8,"UtilityNetwork-Electric",

0);

ads_namessObjsForCleanup;

acedSSGet("X",NULL,NULL,pFilteredEntitySelectionRb,ssObjsForCleanup);

acutRelRb(pFilteredEntitySelectionRb);

Youcanalsogetaselectionsetofobjectstobeanchored(theanchorset).Anchoredobjectsarenotrepositionedbythecleanupprocess,butremainfixedwhileothersarerepositionedaroundthem.

ads_namessObjsToAnchor;

acutPrintf("\nSelecttheobjectstoserveasananchor.");

acedSSGet(NULL,NULL,NULL,NULL,ssObjsToAnchor);

TheacedSSGetfunctionpromptstheusertoselectobjectsandreturnsaselectionset.Thisfunctioncanalsobeusedwitharesbuftofilterselectedobjects.Makesuretoreleaseselectionsetswhenfinishedwiththem,usingacedSSFree()

4. Setcleanupvariablesusingtpm_varsetwiththeclean_var_idthatyouallocatedinstep2.Afewofthesevariablesspecifycleanupactions,butmostofthemspecifyhowcleanupactionswillbeperformed.

//Setthecleanupvariable"LINK_ERROR"forbreakcrossing.

char*pszConfigVarName="LINK_ERROR";

structresbuf*pLinkErrorVarValRb=acutBuildList(

RTSHORT,2,

0);

intresultCode=tpm_varset(

cleanupVarId,

pszConfigVarName,

pLinkErrorVarValRb);

acutRelRb(pLinkErrorVarValRb);

//Setthecleanupvariable"INCLUDEOBJS_AUTOSELECT".

//Mustbeincludedwithafilteredselectionset.

pszConfigVarName="INCLUDEOBJS_AUTOSELECT";

structresbuf*pIncludeObjsVarValRb=acutBuildList(

RTSHORT,0,

0);

resultCode=tpm_varset(

cleanupVarId,

pszConfigVarName,

pIncludeObjsVarValRb);

acutRelRb(pIncludeObjsVarValRb);

//Setthecleanupvariable"INCLUDEOBJS_LAYERS".

//Mustbeincludedwithafilteredselectionset.

pszConfigVarName="INCLUDEOBJS_LAYERS";

structresbuf*pIncludeObjsLyrVarValRb=acutBuildList(

RTSTR,"UtilityNetwork-Electric",

0);

resultCode=tpm_varset(

cleanupVarId,

pszConfigVarName,

pIncludeObjsLyrVarValRb);

acutRelRb(pIncludeObjsLyrVarValRb);

Beforesettingcleanupvariables,youcanloadacleanupprofileifyousavedonepreviously,andinthatwaysetmanyvariablesatonce.Usetpm_cleanprofileload.

resultCode=tpm_cleanprofileload(

cleanupVarId,

"C:\\profile.dpf");

Ifyouspecifyanexplicitlistofcleanupactions,notethatthosewillbetheonlyactionsperformed.CleanupactionsspecifiedbythevariablesNODE_ERROR,LINK_ERROR,andGENERALIZEwillbeignored,aswellasanysettingspecifictothemonly,suchasCORRIDOR's,whichdefinesthetoleranceforGENERALIZE.Usinganactionlististhebestwaytospecifycleanupactions,becauseyoucanspecifytheorderinwhichtheyexecute,andyoucanincludethesameactionmorethanonce.Usingvariablestospecifycleanupactionsisanoldertechnique,whichisstillsupportedforthesakeofolderscripts,butitisdeprecatedfromAutoCADMap3D6onward.NoteWhenyouinserttheSimplifyObjectsaction(cleangrouptype128),itisalwayslistedfirst,andyoucannotinsertitmorethanonce.Withanexplicitlistofcleanupactions,notethatcertainindividualactionscanhaveindividualtolerancesettings(andinsomecases,othersettingsalso).SeeCleanupActionVariables.Whenyouareaboutto

insertanactionintotheactionlist,youcanusetpm_varsetwiththeaction_var_idthatyouallocatedinstep2tosetvariablesforthisactionbeforecallingtpm_cleanactionlistins.Youcancontinuallyresetandreusethesamesetofcleanupactionvariableswitheachactionthatyouinsert.

//SetCLEAN_TOLcleanupvariableforsimplifyobjects,(weeding).

pszConfigVarName="CLEAN_TOL";

structresbuf*pCleanTolVarValRb=acutBuildList(

RTREAL,2.0,

0);

resultCode=tpm_varset(

cleanupActionVarId,

pszConfigVarName,

pCleanTolVarValRb);

acutRelRb(pCleanTolVarValRb);

Insertacleanupactionforsimplifyobjectsbyspecifyingthecleanupvariablesid(real)returnedbytpm_cleanalloc(),theindexatwhichtheitemwillbeinsertedintothelist,thecleangrouptypecode,(seetpm_cleangrouptypeforalistoftypes)andthecleanupactionvariableid(real)returnedbytpm_varalloc().

resultCode=tpm_cleanactionlistins(

cleanupVarId,

0,

128,

cleanupActionVarId);

Insertanadditionalcleanupactionforbreakcrossingobjects.Theindexpositionof-1isforthelastposition.

resultCode=tpm_cleanactionlistins(

cleanupVarId,

-1,

2,

cleanupActionVarId);

Atanypointwhileyouaresettingcleanupvariables,orafteryouhavefinished,youcansavethecurrentcleanupprofileusing

tpm_cleanprofilesave.

resultCode=tpm_cleanprofilesave(

cleanupVarId,

"C:\\profile.dpf");

NotethatsavedprofilesareXMLfiles.Youcanvieworedittheminatexteditorasyoucanwithsavedqueries(whichareAutoLISPscripts).SeeEditingQueryFiles.

5. Calltpm_cleaninittoaddcleanupvariablesandtheselectionsetofobjectstocleantothecleanupmodel.

resultCode=tpm_cleaninit(

cleanupModelId,

cleanupVarId,

ssObjsForCleanup);

Ifyouhavecollectedaselectionsetofobjectstobeanchored,firstcalltpm_cleaninitanchorsetbeforecallingtpm_cleaninit.

resultCode=tpm_cleaninitanchorset(

cleanupModelId,

cleanupVarId,

ssObjsForAnchor);

Thecleanupmodelisnowcomplete.

Toexecutethecleanup

1. Beginthecleanupprocesswithtpm_cleanstart.

resultCode=tpm_cleanstart(cleanupModelId);

2. Executecleanupactions(processcleanupgroups)untilcleanupiscomplete.Witheachcleanupgroup,witheacherror,markandfixit.

resultCode=tpm_cleangroupnext(cleanupModelId);

if(resultCode==RTNORM){

while(!(tpm_cleancomplete(cleanupModelId))){

longlCleanErrors=0;

tpm_cleangroupqty(cleanupModelId,&lCleanErrors);

for(inti=0;i<lCleanErrors;i++){

resultCode=tpm_cleanerrorcur(cleanupModelId,i);

resultCode=tpm_cleanerrormark(cleanupModelId);

resultCode=tpm_cleanerrorfix(cleanupModelId);

}

resultCode=tpm_cleangroupnext(cleanupModelId);

}

}

else{

acutPrintf("\nNothingtoclean.");

}

3. Updatethedrawingwithtpm_cleanend.

resultCode=tpm_cleanend(cleanupModelId);

Optional,Toclearthecleanupmodelwithoutupdatingthedrawing,usetpm_cleancancel.

resultCode=tpm_cleancancel(cleanupModelId);

4. Freethecleanupmodel.

resultCode=tpm_cleanfree(cleanupModelId);

5. Freetheselectionset.

resultCode=acedSSFree(ssObjsForCleanup);

Pleasesendusyourcommentaboutthispage

Annotation

UseAutoCADMap'sannotationfeaturetoindicatetextualvaluesonadrawingobject.

Thesetextualvaluesmightbeattributes(suchasobjectdata),displayproperties(suchasalineweight),orgeometricvalues(suchasthelinedirection).Inaddition,youcanaddgraphics,suchasarrows,statictext,orothergeometry,toyourannotationbyusingstandardAutoCADdrawingcommands.AnnotationfunctionsareavailableintheAcMapAnnotationManagernamespace.SeealsoOtherInformationSources.

Topicsinthissection

AnnotationDetails

Pleasesendusyourcommentaboutthispage

AnnotationDetails

UseAutoCADMap3D'sannotationfeaturetoindicatetextualvaluesonadrawingobject.

CreatingAnnotationTemplates

SettingAnnotationTemplateProperties

SettingAnnotationTextandExpressions

InsertingAnnotationReferences

UpdatingAnnotations

DeletingAnnotations

ManagingAnnotations

OtherInformationSources

AnnotationSamplesAnnotationNamespace

CreatingAnnotationTemplates

Beforeyoucanaddannotationtoadrawing,youfirstmustcallCreateAnnotationTemplate()todefineanannotationtemplatethatspecifieswhatinformationwillbeincludedandhowitwillbedisplayed.CallAnnotationTemplateExists()tocheckwhetheraspecifictemplatealreadyexists;ifitdoesexist,CreateAnnotationTemplate()won'toverwriteit,butratherwillreturnanullobjectID.

Forannotationsource-codesamples,seeAnnotationSamples.

char*pszTemplateName="MyAnnotationTemplate";

AcDbObjectIdidCreatedAnnTem;

if(!AnnotationTemplateExists(pszTemplateName))

{

//CreateatemplatewiththenamestoredinpszTemplateName.

idCreatedAnnTem=CreateAnnotationTemplate(pszTemplateName);

//Testwhetherthetemplate'sobjectIDisvalid.

if(idCreatedAnnTem!=AcDbObjectId::kNull)

{

}

}

Backtotop

SettingAnnotationTemplateProperties

Aftercreatinganannotationtemplate,youcanretrieveorsetitsfollowingstaticproperties:

Color-GetTemplateColor()/SetTemplateColor()

Layer-GetTemplateLayer()/SetTemplateLayer()

Linetype-GetTemplateLinetype()/SetTemplateLinetype()

Lineweight-GetTemplateLineWeight()/SetTemplateLineWeight()

Rotation-GetTemplateRotation()/SetTemplateRotation()

Scalefactor-GetTemplateScaleFactor()/SetTemplateScaleFactor()

Forannotationsource-codesamples,seeAnnotationSamples.

Acad::ErrorStatusacErrStatus;

char*pszTemplateName="MyAnnotationTemplate";

AcCmColoracclrInColor;

char*pszInLayerName="aLayer";

//Setafewtemplateproperties.

acErrStatus=SetTemplateScaleFactor(pszTemplateName,2.0);

acErrStatus=SetTemplateRotation(pszTemplateName,PI);//PIradians=180degrees

acclrInColor.setColorIndex(1);//Red.

acErrStatus=SetTemplateColor(pszTemplateName,acclrInColor);

acErrStatus=SetTemplateLayer(pszTemplateName,pszInLayerName);

//Getthescalefactor.

doubledOutScaleFactor;

acErrStatus=GetTemplateScaleFactor(dOutScaleFactor,pszTemplateName);

Backtotop

SettingAnnotationTextandExpressions

Tosetthetextthatappearsonanannotation,callCreateAnnotationText()tocreateatextobjectandsetitsproperties(tag,height,color,justification,andsoon),andthencallSetExpressionString()tosetthevaluethatappears.TheexpressioncanbeanyvalidcombinationoffunctionsandvariablesthatcanappearintheAutoCADMap3DExpressionEvaluator.OneformofSetExpressionString()takesachar*expression,andtheotherformtakesanAcMapExpressionexpression.Toretrieveanexpression,callGetExpressionString().GetExpressionString()andSetExpressionString()takeaneAnnotationExpressionFieldsargumentthatindicateswhichexpressiontoretrieveorstore.UseIsAnnotationText()todeterminewhetheraparticularattributedefinitionisanannotationtextentity.

Forannotationsource-codesamples,seeAnnotationSamples.

#includedbmain.h//NeededforacdbOpenObject().

Acad::ErrorStatusacErrStatus;

//idCreatedAnnTemwascreatedearlierwithCreateAnnotationTemplate().

AcDbObjectIdidTagText;

acErrStatus=CreateAnnotationText(idTagText,idCreatedAnnTem);

//Openthenewlycreatedtextobjectforwrite.

AcDbAttributeDefinition*pTagText=NULL;

acErrStatus=acdbOpenObject((AcDbObject*&)pTagText,idTagText,AcDb::kForWrite);

//Checkifthisisanannotationtextobject.

if(IsAnnotationText(pTagText))

{

//Setafewpropertiesforthetextobject.

pTagText->setTag("Area");//Alwayssetthetagattribute.

pTagText->setPosition(AcGePoint3d(0.0,0.0,0.0));

pTagText->setHeight(0.5);

pTagText->setVerticalMode(AcDb::TextVertMode::kTextVertMid);

pTagText->setHorizontalMode(AcDb::TextHorzMode::kTextCenter);

//Setthevalueoftheexpressiontodisplay

//theareaoftheassociatedentity.

char*pszExpressionString=".AREA";

//Storetheexpressionwiththeannotationtextobject.

acErrStatus=SetExpressionString(kpszExpressionString,pTagText,kAttDefAnnotationString);

}

//Printthevalueoftheexpressionthatwejustset.

char*pszOutExpression=NULL;

acErrStatus=GetExpressionString(pchOutExpression,pTagText,kAttDefAnnotationString);

if(acErrStatus==Acad::eOk)

{

acutPrintf("Tag=%s.Expressionstring=%s\n",pTagText->tag(),pchOutExpression);

acutDelString(pchOutExpression);

}

Backtotop

InsertingAnnotationReferences

CallInsertAnnotationReference()toattachanannotationreferencetoaparticularentity.Optionally,youcanoverridethedefaultpropertyvaluesofthebaseannotationtemplatewhenyouinsertanewannotationreference:OneformofInsertAnnotationReference()usesthepropertyvaluesofanexistingannotationreferencetosetthevaluesofthenewreference,andtheotherformletsyouspecifyanAnnotationOverridesstructofexplicitoverridevalues.Toattachanannotationreferencetomorethanoneentity,callInsertAnnotationReferences()(whichalsosupportspropertyoverrides).

Forannotationsource-codesamples,seeAnnotationSamples.

AcDbObjectIdidNewBlkRefId;//OutputobjectIDofthenewlycreatedannotationreference.

char*pszTemplateName="MyAnnotationTemplate";//Nameofexistingtemplate.

AcDbObjectIdidAssocEnt;//ObjectIDofentitytoattachannotationto.

Acad::ErrorStatusacErrStatus;

//Drawacircletoassociatetheannotationwith.

AcGePoint3dptCenter(0,0,0);

AcGeVector3dvcNorm(0,0,1);

doubledInRadius=5.5;

idAssocEnt=DrawCircle(ptCenter,vcNorm,dInRadius);

//Attachtheannotationreferencetothecircle.

//Theannotationwillappearinthecurrentdrawing

//ifitsannotationtextexpression(s)canbeevaluated.

//TheMyAnnotationTemplatetextexpressionissetto.AREA.

acErrStatus=InsertAnnotationReference(idNewBlkRefId,pszTemplateName,idAssocEnt);

//Testtoseeiftheinsertionsucceeded.

if(acErrStatus!=Acad::eOk)

{

//Handletheerror...

}

Backtotop

UpdatingAnnotations

Ifanentityassociatedwithanannotationreferencechanges,callRefreshAnnotationReferences()torefreshtheannotation.Ifanannotationtemplatechanges,callUpdateAnnotationReferences()toupdatetheannotationreferencesbasedonthattemplate.Bothfunctionsletyoucontrolhowtheannotationreference'spropertyvaluesareupdated.

Forannotationsource-codesamples,seeAnnotationSamples.

char*pszTemplateName="MyAnnotationTemplate";//Nameofexistingtemplate.

boolbFullAnnotation;

boolbRetainLocal;

Acad::ErrorStatusacErrStatus;

bFullAnnotation=false;//Re-evaluateonlythetextstring-don'tchangeotherproperties.

acErrStatus=RefreshAnnotationReferences(pszTemplateName,bFullAnnotation);

bRetainLocal=true;//Don'tdiscardthelocalpropertyvalues.

acErrStatus=UpdateAnnotationReferences(pszTemplateName,bRetainLocal);

//Testtoseeiftheupdatesucceeded.

if(acErrStatus!=Acad::eOk)

{

//Handletheerror...

}

Backtotop

DeletingAnnotations

Todeleteanannotationtemplate,callDeleteAnnotationTemplate().Youcandeleteonlytemplateswithnoannotationreferences,whichyoucancheckwithIsAnnotationTemplateReferenced().AnnotationTemplateReferencedObjIds()listsallofatemplate'sreferences,whichyoumustdeletebeforeyoucandeletethetemplate.Deleteanannotationreferenceinthesamewaythatyouwoulddelete

anyAutoCADobject.

Forannotationsource-codesamples,seeAnnotationSamples.

#includedbmain.h//NeededforacdbOpenObject().

char*pszTemplateName="MyAnnotationTemplate";//Templatetodelete.

Acad::ErrorStatusacErrStatus;

if(AnnotationTemplateExists(pszTemplateName))

{

//Ifthetemplatehasanyannotationreferences,deletethem.

if(IsAnnotationTemplateReferenced(pszTemplateName))

{

AcDbObjectIdArrayarrOutIdObjs;

AcDbObject*pObj=NULL;

if((AnnotationTemplateReferencedObjIds(arrOutIdObjs,pszTemplateName))==Acad::eOk)

{

//Open,erase,andcloseeachreturnedobjectreference.

while(arrOutIdObjs.length())

{

acErrStatus=acdbOpenObject(pObj,arrOutIdObjs.first(),AcDb::kForWrite);

if((acErrStatus==Acad::eOk)&&(pObj))

{

pObj->erase();

pObj->close();

pObj=NULL;

//RemovetheIDoftheerasedobject.

arrOutIdObjs.removeFirst();

}

else

{

//Handletheerror...

}

if((DeleteAnnotationTemplate(pszTemplateName))!=Acad::eOk)

{

//Handletheerror...

}

}

Backtotop

ManagingAnnotations

Youcanuseseveralgeneralfunctionstomanageannotationtemplatesandreferences.GetTemplateNames()liststheannotationtemplatesdefinedinthecurrentdrawing.AutodeskMapstoresanannotationtemplateasablock(AcDbBlockTableRecord)andanannotationreferenceasablockreference(AcDbBlockReference).

IsAnnotationTemplate()determineswhetheranAcDbBlockTableRecordisanannotationtemplateandAnnotationTemplateBlockDefinitionId()getsatemplate'sAcDbBlockTableRecord.

IsAnnotationBlockReference()determineswhetheraAcDbBlockReferenceisanannotationreference;AnnotationBlockReferenceAssociatedObjectId()returnstheIDoftheobjectassociatedwithaspecificannotationreference;andTemplateNameBTRPrefix()returnsthespecialprefixstring("ACMAP_ANN_TEMPLATE_")thatAutodeskMapsilentlyprependstoeachannotationtemplatename.

Forannotationsource-codesamples,seeAnnotationSamples.

//Getalltheannotationtemplatenames.

Acad::ErrorStatusacErrStatus;

AcArray<char*>acarrTemNameArray;

acErrStatus=GetTemplateNames(acarrTemNameArray);

if((acErrStatus==Acad::eOk)&&(!(acarrTemNameArray.isEmpty())))

{

//Processthetemplates...

}

Backtotop

OtherInformationSources

FormoreinformationaboutannotationinAutoCADMap3D,chooseHelp&gt;AutodeskMapHelp&gt;Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)&gt;Annotation.

ForanannotationtutorialinAutoCADMap3D,chooseHelp&gt;Tutorials&gt;Contentstab,andthenchoose"AddingAnnotationsto

Objects".

FormoreinformationaboutexpressionsinAutoCADMap3D,chooseHelp&gt;AutodeskMapHelp&gt;Contentstab(orpressF1),andthennavigatetoExpressionEvaluator.

Backtotop

AnnotationSamples

Toviewcodesamplesofannotationfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\Annotation.

Backtotop

AnnotationNamespace

Toviewtheannotationnamespace,clickthefollowinglink:

AcMapAnnotationManagerNamespace

Pleasesendusyourcommentaboutthispage

DisplayManager

Managesthedisplayofselectedobjectsinadrawingforthemingorhighlighting.

Formoreinformation,see

DisplayManagerinObjectARXReferenceHelp.

DisplayManagersamplecode,whichislocatedintheMapSamples\DisplayManagementfolderofAutoCADMap3DObjectARXinstallations.

DisplayManagerintheUIdocumentation,AutoCADMap3DHelp.

Pleasesendusyourcommentaboutthispage

UserManagement

TheAutoCADMap3Duser-managementfeatureprovidesuser-andsession-managementtoolsforsystemadministrators.

Topicsinthissection

UserManagementDetail

Pleasesendusyourcommentaboutthispage

UserManagementDetail

UserManagement

OtherInformationSources

UserManagementSamplesUserManagementClassesandGlobals

UserManagement

TheAcMapSessionclassprovidesthefollowinguserandsessionfunctions.TheAcMapGetSession()globalfunctionretrievestheAutoCADMap3Dsessionpointer,aninstanceofAcMapSession.

Retrievealiases-GetAliases()

Retrieveerrorstack-GetErrorStack()

Retrieveprojectiterator-GetProjectIterator()

Loginauser-LogIn()

Listregisteredusers-GetUserList()

Retrievethecurrentuser-GetCurrentUser()

Retrieve/setauser'srights-GetUserRights()*/SetUserRights()*

Lock/unlockAutodeskMap-Lock()/Unlock()

RetrieveAutoCADMap3DObjectARXAPIversion-ArxApiVersion()

Retrieve/setworkspacerectangle-GetWSpaceRectangle()/SetWSpaceRectangle()

ExecuteAutoCADMap3Dcommand-InvokeCommand()

ExecuteAutoCADMap3DAPIfunction-InvokeFunction()

RetrieveAutoCADMap3Dproject-GetProject()(twoforms)

RetrieveAutoCADdocument-GetDocument()

Add/removesessionreactor-AddSessionReactor()/RemoveSessionReactor()

Add/removeoptionsreactor-AddOptionsReactor()/RemoveOptionsReactor()

Retrieve/setoptionvalues-GetOptionValue()(threeforms:123)/SetOptionValue()(threeforms:123)

Optionnodetest-IsOptionNodeEnabled()

SettheOptionsdialogboxactivepage-SetActiveOptionPage()

Retrievetheusers'rootfolder-getAllUsersRootFolder()

RetrieveAutoCADMap3Dapplicationservices-GetApplicationServices()

Createanewuser-CreateUser()*

Deleteanexistinguser-DeleteUser()*

Changeauser'spassword-ChangePassword()*

RetrieveAutoCADMap3Dproject-GetProjectForDb()

Foruser-managementsource-codesamples,seeUserManagementSamples.

OtherInformationSources

FormoreinformationaboutusermanagementinAutoCADMap3D,chooseHelp&gt;AutodeskMapHelp&gt;Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)&gt;SettingUpAutoCADMap3DDrawings&gt;SettingOptions&gt;SettingUpUsers.

UserManagementSamples

Toviewcodesamplesofuser-managementfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\UserManager.

UserManagementClassesandGlobals

Toviewtheuser-managementclassesandglobals,clickthefollowinglinks:

AcMapSessionClassAcMapGetSession()GlobalFunction

Pleasesendusyourcommentaboutthispage

MapPlottingandPublishing

ThistopicdescribesplottingandpublishingmapsusingMapBookclasses.

Topicsinthissection

MapPlottingandPublishingDetail

Pleasesendusyourcommentaboutthispage

MapPlottingandPublishingDetail

Althoughtheglobal-functionAPIformapplottingremainsinplace,andexistingcodethatisbasedonitisstillvalid,newdevelopmentforplottingmapsshoulduseMapBookclasses.

Formoreinformation,see

MapBookinAutoCADMap3DObjectARXReferenceHelp.

MapBooksamplecode,whichislocatedintheMapSamples\PlottingfolderofAutodeskMapObjectARXinstallations.

MapBookintheUIdocumentation,AutoCADMap3DHelp.

Pleasesendusyourcommentaboutthispage

ManagedWrapperClasses

ObjectARXpresentedasmanagedC++.

Topicsinthissection

ManagedWrapperClassesDetail

Pleasesendusyourcommentaboutthispage

ManagedWrapperClassesDetail

ThefollowingdiscussionassumesthatyouarefamiliarwithmanagedC++andmanagedwrapperclassesinAutoCADObjectARX.RefertothemanagedwrappersectionsinAutoCADObjectARXHelp.

GetandSetFunctionsandProperties

IfyouareusingC#orVB.NETtoaddressthemanagedwrapperclassesAPI,notethatget_xxandset_xxfunctionsareaddressedasproperties,andthepropertynameisthexxpartofthecorrespondingfunctionnames.Iftherearematchingget_xxandset_xxfunctions,thepropertyisread-write.Ifthereisonlyaget_xxfunction,thepropertyisread-only.Inafewcases,wherethereisonlyaset_xxfunction,thepropertyiswrite-only.

OptionStringsOptionProperties

GettingandsettingprojectorsessionoptionsisnotthesamewithmanagedwrapperclassesasitiswithObjectARX.

TogetorsetasessionorprojectoptionusingObjectARX,useaGetOptionValueorSetOptionValuefunction.Specifythetargetoptionbypassingtheoptionname.Forexample,tosetthelogfilenameforasession(AcMapSessionobject,whichcorrespondstotheMapApplicationobject,ortheapplication,inmanagedwrappercontext),youpasstheoptionnameandafilename:

pSession->SetOptionValue("LogFileName","filename.ext");

Togetorsetthesameoptioninmanagedwrappercontext,firstusetheMapApplication::OptionspropertytogettheSystemOptionsobject,andthenuseanoption-specificSystemOptionsproperty:

oSysOptions.LogFileName="filename.ext";

strLogFile=oSysOptions.LogFileName;

GettingApplicationandProjectObjects

AutodeskMapobjectsarerelatedinacontainmenthierarchy,withtheApplicationobjectattheroot.ToaccessAutoCADMap3Dobjects,firstgettheApplicationobject,andthenusetheApplication::ActiveProjectpropertytogetthecurrentproject(aProjectModelobject).

NAMESPACE_MAP3D::MapApplication*mapApi=Autodesk::HostMapApplicationServices::Application;

NAMESPACE_MAP3D_PROJECT::ProjectModel*pProj=mapApi->ActiveProject;

Withaprojectinhand,useProjectModelpropertiestogetobjectsthatitcontains.Forexample,itsdrawingset(DrawingSetobject).

NAMESPACE_MAP3D_PROJECT::DrawingSet*pDSet=pProj->DrawingSet;

SampleCode

Togetmanaged-wrappersamples,openMapSamples\DotNetinanAutoCADMap3DObjectARXinstallation.

Pleasesendusyourcommentaboutthispage

Notes,Tips,andWarnings

Topicsinthissection

Colors

Pleasesendusyourcommentaboutthispage

Colors

ColorscanbespecifiedorreturnedasAutoCADcolorindexesortruecolors.

AutoCADColorIndexes(ACIs)

ThevalidACIformatsare

ColorIndexes,integerstringsfrom0through256.Forexample,"123".Notethatindexes0and256donotspecifycolorsliterally,as1through255do,butlogically.See"LogicalColors"below.Andnotethatindexes8and9(adarkgrayandalightgray),togetherwiththenamedcolors(see"ColorNames"below),arecollectivelycalledthestandardcolors.

ColorNames,whichcorrespondtoindexes1through7.Thecolornamesarered,yellow,green,cyan,blue,magenta,andwhite.Forexample,"yellow"(alwaysdouble-quoted).Notethatindex7,thecolornamedwhite,displaysaswhiteorblackdependingonbackgroundcolor.

Index Name1 Red2 Yellow3 Green4 Cyan5 Blue6 Magenta7 White

LogicalColors,whichcorrespondtoindexes0and256.ThelogicalcolorsareByBlock(0)andByLayer(256),andtheyreflectthecurrentblockandlayercolorsrespectively.Forexample,"ByBlock"(alwaysdouble-quoted).Notethat

ByBlockandByLayercanreturntruecolorsorACIs.

FormoreinformationaboutACIs,

1. InAutoCADMap3D,clickFormat>Color.

2. IntheSelectColordialogbox,clickHelp.

TrueColors

Bytruecolorswemean24-bitcolor:threeRGBcomponents,8bitseach,withnoalphacomponent(thatis,notransparencyvalue).

Thevalidtrue-colorformatsare

RGBTriplets,whereeachcomponentisanintegerfrom0through255.Forexample,"255,0,0".RGBtripletsarewrappedindoublequotesexceptwhentheyareusedinqueryconditions,inwhichcasetheymustalwaysbewrappedinescapeddoublequotes('\"').See"ColorPatterns"below.

ColorBookColors,suchas"Pantone,123CVC",acompositeoftwocomma-separatednamesrepresentingaColorBookandacolorwithinit.Colorbookstringsarewrappedindoublequotesexceptwhentheyareusedinqueryconditions,inwhichcasetheymustalwaysbewrappedinescapeddoublequotes('\"').See"ColorPatterns"below.Andnomatterwheretheyareused,colorbookstringsmustalwaysbewrappedinescapeddoublequotesiftheycontaincertainspecialcharacters.Ifyouareunsureifacolorbookstringcontainsspecialcharacters,thereisnoharmwrappingitinescapeddoublequotesjusttobesure.

Expressions,suchas".COLOR"or".TRUECOLOR"(alwaysdouble-quoted).".COLOR"alwaysreturnsanACIcolor.Iftheselectedobject'scolorisatruecoloritreturnsthenearestACIequivalent.".TRUECOLOR"returnsatruecoloriftheselectedobject'scolorisatruecolor,oranACIifitscolorisanACI.Notethat".TRUECOLOR",andotherexpressionsthatcanreturntruecolors,returninvalidformatonlyifthetypeargumentof(ade_expreval)is"string".

ColorPatterns,comma-separatedlistsofcolorsinanyofthevalidformats,includingACIcolors,alwaysdouble-quoted.Colorpatternsareusedtoexpressmultiplecolorconditionsincompactformat.Considerthecolorpattern"red,green".Thepseudocodeexpression,color="red,green",islogicallyequivalentto(color="red")OR(color="green").Similarly,color&lt;&gt;"red,green"islogicallyequivalentto(color&lt;&gt;"red")AND(color&lt;&gt;"green").

Becausecolorpatternsarecomma-separatedlists,ColorBookcolorsandRGBcolorsinqueryconditionsarealwaysboundedbyescapeddoublequotes('\"')becausetheyarethemselvescomma-separated.Forexample,thefollowingcolorpatternincludessixcolors:threeACIs,oneRGB,andoneColorBookcolor.

"12,34,56,\"12,34,56\",\"Pantone,123CVC\""

Note NoteYoucanusewildcardcharacterswhenyouspecifyamatchstringforColorBookcolors(butnotforRGBcolors).Forthisreason,anywildcardcharacterinaColorBookstringthatismeanttobetakenliterallymustbeescapedusingabackquote,"`".Forexample,the"."characterinthefollowingstring,normallyawildcardmatchinganynon-alphanumericcharacter,ismeantasaliteral:"My`.Colors,Hot".

ColorsinQueryConditions

YoucanspecifyACIcolorsinqueryconditionsascolornamesorcolorindexes.Butifyouretrievesuchconditions,ACIcolorsarealwaysreportedascolorindexes,becausethatishowtheyarestored,eveniftheywereoriginallyspecifiedascolornames.

However,thisisnotthecasewithcolorpatterns,whichcanincludecolorindexes,colornames,orboth.Ifyouretrieveaqueryconditionwherecolorisspecifiedasacolorpattern,thecolorpatternisreportedasitwasoriginallyspecified.

Pleasesendusyourcommentaboutthispage

top related