![Page 1: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/1.jpg)
BeforeYouBegin
AutoCADMap3DObjectARXDeveloper'sGuidedescribeshowtouseObjectARXclassestoautomateandextendAutoCADMap3D.
AutoCADMap3DObjectARXextendsAutoCADObjectARXintotheAutoCADMap3Ddomain.
TheObjectARXandObjectARX.NETAPIseachcovermostofAutoCADMap3Dfunctionality.Buttheydon'tcoverResourceService,FeatureService,orMappingService.TheseareasarecoveredbytheGeospatialPlatformAPI,whichisexposedas.NETonly.
Topicsinthissection
SourcesofInformationCompatabilityofSDKsTypographicConventions
Pleasesendusyourcommentaboutthispage
![Page 2: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/2.jpg)
SourcesofInformation
TodevelopapplicationsusingAutoCADMap3DObjectARX,youshouldbefamiliarwithAutoCADObjectARXandalsotheAutoCADMap3DandAutoCADapplications.
Forinformationabout...
Referto...
AutoCADObjectARX AutoCADObjectARXHelp,arxdoc.chm,whichislocatedinthedocsfolderofAutoCADMap3DSDKinstallations.
AutoCADMap3DandAutoCAD
AutoCADMap3DHelp,whichislocatedintheHelpfolderofAutoCADMap3Dinstallations.
AutodCADMap3DHelpisespeciallyusefulforundestandinghowAutoCADMap3Dmodelsitsdomain.Forunderstandingdrawingsetsandqueries,forexample.SincedetailedexplanationsoftheseparadigmsareavailableinAutoCADMap3DHelp,AutoCADMap3DSDKHelpexplainsthemonlybrieflyornotatall.BeforeyouattempttoautomateorextendanAutoCADMap3Dfeature,besuretoreviewthesubjectinAutoCADMap3DHelp.
Pleasesendusyourcommentaboutthispage
![Page 3: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/3.jpg)
CompatabilityofSDKs
TheAutoCADMap3DSDKmustbeinstalledinanexistingAutoCADSDKinstallation,andtheAutoCADMap3DSDKandAutoCADSDKversionsmustbecompatiblewitheachotherandwiththeversionofAutoCADMap3Dthatyouareextending.Forexample,theAutoCADMap3D2008SDKmustbeinstalledintoanexistingAutoCAD2008SDKinstallation,andyouneedbothtobuildObjectARXapplicationsforAutoCADMap3D2008.
Pleasesendusyourcommentaboutthispage
![Page 4: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/4.jpg)
TypographicConventions
Textelement Descriptionboldsansserif Textyouenteratthe
AutoCADMap3Dcommandprompt.
italic Namesoffilesanddirectories.
monospacefont Samplecode.
Note NoteAllfilenamesanddirectorypathsinAutoCADMap3Darecasesensitive.
Pleasesendusyourcommentaboutthispage
![Page 5: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/5.jpg)
DrawingSets
Thecollectionofdrawingsusedinaparticularprojectistheproject'sdrawingset.
Topicsinthissection
DrawingSetsDetail
Pleasesendusyourcommentaboutthispage
![Page 6: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/6.jpg)
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.
![Page 7: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/7.jpg)
SavingAttachedDrawings
If,aftermodifyinganattacheddrawing,youwanttosavethechangesinthesourcedrawing,youmustspecifythesetofdrawingobjectstobesavedinasaveset.
Savinganattacheddrawingwithitsdrawingobjectsistypicallyathree-partprocedure:
1. LockthedrawingforwritingusingAcMapAttachedDrawing::LockForWrite.
2. ClonethedrawingobjectsthatyouwishtosaveusingoneoftheAcMapAttachedDrawingclass'sfunctions.
3. Savethechangesbacktothedrawing'ssourcefileusingAcMapAttachedDrawing::Save.
ForMoreInformation
Formoreinformationaboutdrawingsets,seetheUIdocumentation,AutodeskMapHelp.
Pleasesendusyourcommentaboutthispage
![Page 8: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/8.jpg)
DrawingSetSample
Topicsinthissection
DrawingSetSample
Pleasesendusyourcommentaboutthispage
![Page 9: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/9.jpg)
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(
![Page 10: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/10.jpg)
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;
![Page 11: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/11.jpg)
}
}
//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"))
{
![Page 12: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/12.jpg)
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"))
{
![Page 13: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/13.jpg)
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
![Page 14: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/14.jpg)
Queries
Aqueryisthemechanismbywhichtheapplicationretrievesasubsetofobjectsfromasourcedrawing,orfromanexternaldatabaseassociatedwithasourcedrawing,foruseintheprojectdrawing.
Topicsinthissection
QueriesDetail
Pleasesendusyourcommentaboutthispage
![Page 15: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/15.jpg)
QueriesDetail
Afteraqueryhasbeendefined,itcanbesavedexternallyandsubsequentlyloadedintoanapplication,whereitcanbeexecutedormodified.
Thebuildingblocksforcreatingaquerydefinitionarequeryconditionsandquerybranches.
QueryConditions
Thecriteriathatthequeryusestoselectobjectsareexpressedinqueryconditions.Therearefourtypesofqueryconditions.
DescriptionLocationConditions Basedonthelocation
ofobjectsrelativetoaboundary.Thereareseveralboundarytypes.SeeLocationBoundariesbelow.
PropertyConditions BasedonaparticularAutoCADproperty.
DataConditions Basedonobjectdata?informationaboutdrawingobjectsthatisstoredwithdrawingobjectsthemselves.
SQLConditions Basedondataaboutdrawingobjectsthatisstoredinexternaldatabasetablesandis
![Page 16: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/16.jpg)
specifiedbytheWHEREclauseofaSQLquery.
LocationBoundaries
Thereareseveraltypesoflocationboundaries.TheyareallrepresentedbydescendentsoftheAcMapLocationBoundaryclass,asillustratedinthefollowingdiagram.
Formoreinformationaboutqueryconditiontypes,refertoAutoCADMap3DHelp.OntheContentstab,clickUsingAutoCADMap3D>Queries>DefiningQueries.
QueryBranches
Querybranchesaretreescomposedofqueryconditions,possiblysubordinatequerybranches,andjoinoperators,whichconnectthecomponents.
Thefollowingdiagramillustratesthestructureofasimplequerybranch,inwhicha,b,andcarequeryconditionsandANDandORarejoinoperators.Itexpressesthequery,aANDborc.
![Page 17: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/17.jpg)
Bothquerybranchesandqueryconditionsinheritfromthesamebaseclass,asshowninthefollowingdiagram.
Tobuildaquery
1. Createoneormorequeryconditions(alsocalledqueryunitsoroperands).
2. Createoneormorequerybranches.
3. Appendorinsertqueryconditionsontothebranch(es).
4. CreatethequerydefinitionbypassingthequerybranchtotheAcMapQuery::Definefunction.
5. CreatethequeryasanobjectintheprojectusingtheAcMapProject::CreateQueryfunction.Thismakesthequeryavailableto
![Page 18: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/18.jpg)
theapplication.
6. Savethequerydefinitioninanexternalfileorquerylibrary.
Toexecuteaquery
1. Youmaywanttosetthemode,enableordisablepropertyalteration,orcreateareporttemplateforthequery.
2. CallAcMapQuery::Runtoexecutethequery.
ForMoreInformation
Formoreinformationaboutqueries,seetheUIdocumentation,AutoCADMap3DHelp,andtheMapSamplesfolderofObjectARXinstallations.
Pleasesendusyourcommentaboutthispage
![Page 19: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/19.jpg)
QuerySample
Thefollowingsampledemonstratesqueryoperations.
Topicsinthissection
QuerySampleCode
Pleasesendusyourcommentaboutthispage
![Page 20: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/20.jpg)
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
);
![Page 21: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/21.jpg)
//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
![Page 22: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/22.jpg)
PropertyAlteration
Propertyalterationdoesnotaffectcorrespondingobjectsinthesourcedrawingordrawings(unlessyoudeliberatelysavethequeriedobjectsback).Theprocessiscontrolledbyasetofoneormorepropertyalterations,eachofwhichdescribeshowaparticularpropertyofqueriedobjectsshouldbedisplayed.Allthepropertyalterationsforaparticularqueryarecontainedinthequery'spropertyalterationdefinition.
Topicsinthissection
PropertyAlteration
Pleasesendusyourcommentaboutthispage
![Page 23: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/23.jpg)
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
![Page 24: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/24.jpg)
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.
![Page 25: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/25.jpg)
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
![Page 26: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/26.jpg)
PropertyAlterationSample
Thisexampleshowshowtocreaterangelinesandalterations.
Topicsinthissection
PropertyAlterationSample
Pleasesendusyourcommentaboutthispage
![Page 27: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/27.jpg)
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;
}
![Page 28: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/28.jpg)
}
}
//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");
![Page 29: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/29.jpg)
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(
![Page 30: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/30.jpg)
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;
![Page 31: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/31.jpg)
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);
![Page 32: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/32.jpg)
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)
![Page 33: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/33.jpg)
{
//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
![Page 34: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/34.jpg)
deletepCurrentQuery;
}
}
}
}
catch(...)
{
//dosomeerrorhandling
}
}
//END
Pleasesendusyourcommentaboutthispage
![Page 35: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/35.jpg)
DesigningQueryableCustomObjects
IfyouareusingAutoCADObjectARXtocreateAcDbcustomobjects,youmustmakesurethattheywillberetrievableusingAutoCADMap3Dqueries.
Topicsinthissection
DesigningQueryableCustomObjectsDetails
Pleasesendusyourcommentaboutthispage
![Page 36: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/36.jpg)
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
![Page 37: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/37.jpg)
Layer AcDbEntity NoneLinetype AcDbEntity None
NoteObjectTypenamespecifiedviaspecialMACRO,suchasACRX_DXF_DEFINE_MEMBERS.
Pleasesendusyourcommentaboutthispage
![Page 38: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/38.jpg)
CustomObjectProtocolExtensions
EnablescustomobjectstoparticipateinAutoCADMap3DoperationssuchasQueryandSaveBack.
Formoreinformation,see
CustomObjectProtocolExtensionsinAutoCADMap3DObjectARXReferenceHelp.
CustomObjectPEsamplecode,whichislocatedintheMapSamples\QueryPESamplefolderofAutoCADMap3DObjectARXinstallations.
Pleasesendusyourcommentaboutthispage
![Page 39: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/39.jpg)
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.
![Page 40: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/40.jpg)
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
![Page 41: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/41.jpg)
ObjectData
Objectdataisnon-graphicalinformationaboutanobjectinadrawing.
Whenyouwanttoaddsuchdatatoadrawingordrawingobject,youcreateanobjectdatatabletostorethedata.
Asingleobjectdatatablecontainsrecordsofasimilarstructure,whichisdefinedbytheobjectdatatable'stabledefinition.Theindividualrecordsinanobjectdatatablemaybeassociatedwithdifferentdrawingobjects.Theassociationbetweenthedataandtheobjectisattheleveloftheindividualrecord,notatthetablelevel.
Theclassesusedtocreateandmanipulateobjectdatatablesare
AcMapODColumnDefinitionAcMapODContainerAcMapODRecordIteratorAcMapODTableAcMapODTableDefinitionAcMapODTableRecordAcMapValue
ForMoreInformation
Formoreinformationaboutobjectdata,seetheUIdocumentation,AutodeskMapHelp,andtheMapSamplesfolderofObjectARXinstallations.
Pleasesendusyourcommentaboutthispage
![Page 42: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/42.jpg)
ObjectDataSamples
Topicsinthissection
CreatinganObjectDataTableAttachingObjectDataTraversingObjectDataAddingorChangingObjectData
Pleasesendusyourcommentaboutthispage
![Page 43: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/43.jpg)
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
![Page 44: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/44.jpg)
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;
![Page 45: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/45.jpg)
Pleasesendusyourcommentaboutthispage
![Page 46: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/46.jpg)
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);
![Page 47: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/47.jpg)
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;
![Page 48: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/48.jpg)
}
8. DeletethememoryallocatedbycallingAcMapODContainer::GetODTableinstep4,andfreethememoryallocatedfortheselectionsetinstep5.
deletepODTable;
acedSSFree(ss);
Pleasesendusyourcommentaboutthispage
![Page 49: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/49.jpg)
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);
![Page 50: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/50.jpg)
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
![Page 51: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/51.jpg)
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;
![Page 52: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/52.jpg)
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());
![Page 53: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/53.jpg)
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);
![Page 54: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/54.jpg)
AcMapValuev=approveCode;
record.Value(i)=v;
pIter->UpdateRecord(record);
}
10. Endtheforloopstartedinstep7anddeletethepointertothetablecreatedwithAcMapODContainer::GetODTable.Endtheforloopstartedinstep6anddeletetheiteratorcreatedinstep5.
}//endfor
if(pTable)deletepTable;
}//endfor
if(pIter)deletepIter;
Pleasesendusyourcommentaboutthispage
![Page 55: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/55.jpg)
CoordinateSystems
TheAutoCADMap3Dcoordinate-systemsfunctionsmeasuregeodeticdistanceandtransformentitiestoaspecifiedcoordinatesystem.
Topicsinthissection
CoordinateSystemsDetails
Pleasesendusyourcommentaboutthispage
![Page 56: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/56.jpg)
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
![Page 57: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/57.jpg)
CoordinateSystemsSamples
Toviewcodesamplesofcoordinate-systemsfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\CoordinateSystem.
Backtotop
CoordinateSystemsGlobals
Toviewthecoordinate-systemsglobals,clickthefollowinglinks:
ade_projwsgeodistance()GlobalFunctionade_projentityforward()GlobalFunctionade_projentitybackward()GlobalFunction
Backtotop
Pleasesendusyourcommentaboutthispage
![Page 58: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/58.jpg)
ConvertingCoordinates
Convertingcoordinatesfromonegeo-referencedcoordinatesystemtoanother.
Topicsinthissection
ConvertingCoordinates
Pleasesendusyourcommentaboutthispage
![Page 59: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/59.jpg)
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.
![Page 60: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/60.jpg)
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
![Page 61: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/61.jpg)
FeatureClassification
UseAutoCADMap3D'sfeature-classificationfeaturetocreatestandardobjectsindrawings.
Topicsinthissection
FeatureClassificationDetail
Pleasesendusyourcommentaboutthispage
![Page 62: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/62.jpg)
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
![Page 63: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/63.jpg)
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:
![Page 64: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/64.jpg)
//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().
![Page 65: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/65.jpg)
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.
![Page 66: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/66.jpg)
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)
{
...
}
}
![Page 67: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/67.jpg)
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()
![Page 68: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/68.jpg)
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
![Page 69: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/69.jpg)
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;
![Page 70: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/70.jpg)
//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
![Page 71: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/71.jpg)
links:
AcMapClassificationManagerClass
AcMapObjClassNamespace
AcMapObjClassDefinitionClass
AcMapObjClassPropertyClass
AcMapObjClassReactorClass
AcMapObjClassSystemClass
Backtotop
Pleasesendusyourcommentaboutthispage
![Page 72: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/72.jpg)
ObjectFilters
TheAutoCADMap3Dobject-filtersfeaturefiltersobjects(entities)inthecurrentdrawingbasedonthespecifiedfilteringcriteria.
Topicsinthissection
ObjectFiltersDetail
Pleasesendusyourcommentaboutthispage
![Page 73: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/73.jpg)
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.
![Page 74: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/74.jpg)
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()
![Page 75: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/75.jpg)
Forobject-filterssource-codesamples,seeObjectFiltersSamples.
OtherInformationSources
FormoreinformationaboutobjectfiltersinAutoCADMap3D,chooseHelp>AutodeskMapHelp>Indextab,andthentypethekeywordsfiltersandqueriestodisplaytherelatedtopics.
ObjectFiltersSamples
Toviewcodesamplesofobject-filtersfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\ObjectFilter.
ObjectFiltersClasses
Toviewtheobject-filtersclasses,clickthefollowinglinks:
AcDbObjectFilterClassAcDbBasicFilterClassAcDbObjectFilterGroupClass
Pleasesendusyourcommentaboutthispage
![Page 76: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/76.jpg)
Import-Export
UseAutoCADMap3D'simport-exportfeaturetoexchangedatainindustry-standardGISandmappingformats.
Topicsinthissection
Import-ExportDetail
Pleasesendusyourcommentaboutthispage
![Page 77: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/77.jpg)
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)
![Page 78: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/78.jpg)
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.
![Page 79: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/79.jpg)
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.
![Page 80: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/80.jpg)
}
//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
![Page 81: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/81.jpg)
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
![Page 82: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/82.jpg)
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()
![Page 83: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/83.jpg)
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
![Page 84: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/84.jpg)
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.
![Page 85: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/85.jpg)
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
![Page 86: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/86.jpg)
AcMapIENameValueIterator Name-valuepairs
Forimport-exportsource-codesamples,seeImport-ExportSamples.
Backtotop
HandlingErrors
Manyfunctionsinthevariousimport-exportclassesreturnanAcMapIE::ErrCodeerrorcode.Whenaparticularfunctionreturnsanerrorcode,readthatfunction'sdocumentationforfunction-specificerrorconditionsratherthanrelyingononlythegenericerrordescriptionsintheAcMapIE::ErrCodedocumentation.
Backtotop
OtherInformationSources
FormoreinformationaboutimportingandexportingmapsinAutoCADMap3D,chooseHelp>AutoCADMap3DHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>ImportingandExportingMaps.
Foranimport-exporttutorialinAutoCADMap3D,chooseHelp>Tutorials>Contentstab,andthenchoose"ImportingandExportingData".
Backtotop
Import-ExportSamples
Toviewcodesamplesofimport-exportfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\ImportExport.
Backtotop
Import-ExportClasses,Namespaces,andGlobals
Toviewtheimport-exportclasses,namespaces,andglobals,clickthefollowinglinks:
![Page 87: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/87.jpg)
AcMapIEColumnClassAcMapIEColumnIteratorClassAcMapIEExporterClassAcMapIEExportReactorClassAcMapIEExpressionTargetIteratorClassAcMapIEFormatClassAcMapIEFormatIteratorClassAcMapIEImporterClassAcMapIEImportReactorClassAcMapIEInputLayerClassAcMapIEInputLayerIteratorClassAcMapIENameValueIteratorClassAcMapIENamespaceAcMapExporterGlobalFunctionAcMapExportFormatIteratorGlobalFunctionAcMapImporterGlobalFunctionAcMapImportFormatIteratorGlobalFunction
Backtotop
Pleasesendusyourcommentaboutthispage
![Page 88: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/88.jpg)
OracleSpatialData
ThistopicdescribesthelatestimplementationoftheOracleSpatialAPI.
Topicsinthissection
OracleSpatialDataDetail
Pleasesendusyourcommentaboutthispage
![Page 89: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/89.jpg)
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.
![Page 90: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/90.jpg)
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
![Page 91: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/91.jpg)
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.
![Page 92: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/92.jpg)
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"
![Page 93: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/93.jpg)
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.
![Page 94: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/94.jpg)
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
![Page 95: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/95.jpg)
AcMapOSEObject
AcMapOSEProject
AcMapOSEQuery
Pleasesendusyourcommentaboutthispage
![Page 96: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/96.jpg)
OracleSpatialSamples
TheOracleSpatialsamples.
ConnectingtoanOracleSpatialDatabaseSubclassingCustomReactorsExportingtoanOracleSpatialDatabaseImportingFromanOracleSpatialDatabaseGettingCorrespondingIDsFilteringObjects
Topicsinthissection
ConnectingtoanOracleSpatialDatabaseSubclassingCustomReactorsExportingtoanOracleSpatialDatabaseImportingfromanOracleSpatialDatabaseGettingCorrespondingIDsFilteringObjects
Pleasesendusyourcommentaboutthispage
![Page 97: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/97.jpg)
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
{
![Page 98: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/98.jpg)
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);
![Page 99: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/99.jpg)
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
![Page 100: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/100.jpg)
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>&);
![Page 101: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/101.jpg)
virtualvoidObjectsExported(std::vector<OValue>&);
};
classMyImportReactor:publicAcMapOSEImportReactor
{
public:
MyImportReactor();
virtual~MyImportReactor();
virtualvoidBeforeRecordImport(constODynaset&);
virtualvoidRecordImported(constODynaset&,AcDbEntity*);
virtualvoidRecordRejected(constODynaset&);
};
Pleasesendusyourcommentaboutthispage
![Page 102: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/102.jpg)
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)
![Page 103: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/103.jpg)
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
{
![Page 104: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/104.jpg)
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
![Page 105: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/105.jpg)
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());
![Page 106: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/106.jpg)
//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
![Page 107: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/107.jpg)
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
![Page 108: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/108.jpg)
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())
{
![Page 109: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/109.jpg)
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();
![Page 110: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/110.jpg)
//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
![Page 111: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/111.jpg)
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
![Page 112: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/112.jpg)
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;
![Page 113: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/113.jpg)
//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
![Page 114: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/114.jpg)
OracleSpatialSampleProjects
TheOracleSpatialsampleprojects.
ImportingFromanOracleSpatialDatabaseStoringBlockDefinitionsinanOracleSpatialDatabaseStoringBlockAttributePositionsinanOracleSpatialDatabase
TheprojectfoldersareintheMapSamples\OracleSpatialfolderinAutoCADMap3DObjectARXinstallations.
NoteThesampleprojectsthatareinMapSamples\OraclearefortheearlierOracleSpatialimplementation,whichisstillsupported,butisnowdeprecated.
Topicsinthissection
ImportingFromanOracleSpatialDatabaseStoringBlockDefinitionsinanOracleSpatialDatabaseStoringBlockAttributePositionsinanOracleSpatialDatabase
Pleasesendusyourcommentaboutthispage
![Page 115: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/115.jpg)
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
![Page 116: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/116.jpg)
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
![Page 117: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/117.jpg)
thecurrentschemaanddisplaysitsSQLstatementinaseparatedialogbox.Youcan'texecutethequery,butyoucanviewit,andyoucancopypartsofittouseinotherqueries.
Torunaquery
ClickImport.
Note
Keepinmindthatthepurposeofthisapplicationistoinstruct.Itlacksextensiveerrorhandling.Useitwithcaution.
Pleasesendusyourcommentaboutthispage
![Page 118: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/118.jpg)
StoringBlockDefinitionsinanOracleSpatialDatabase
OracleSpatialData(Overview)RelatedSamples
The"StoringBlocks"sampleisanObjectARXprojectlocatedintheMapSamples\AcMapFlatOrclBlockfolderinAutoCADMap3DObjectARXinstallations.
Classeshighlighted
IthighlightsthefollowingOracleSpatialclasses.
AcMapOSEExportReactor
Thefollowingclassesareincludedalso,buttheiruseislessextensive.
AcMapOSEConnection
Commandsimplemented
Theprojectcreatesanrxmodulewhichexposesthefollowingcommands.
SAVEBLOCKTOORACLEinstallscustomexportandconnectionreactors.ThesereactorsenablestoringblockdefinitionsinanOracledatabase.
LOADBLOCKSFROMORACLEreadsblockdefinitionsfromanOracledatabaseandplacestheminthetablerecordoftheactiveprojectdrawing.Thiscommandshouldbeexecutedtosetblockdefinitionsinplacebeforeimportingblockreferences.
STOPSAVEBLOCKTOORACLEremovesthecustomreactorsthatwereaddedbySAVEBLOCKTOORACLE.
Note
![Page 119: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/119.jpg)
Keepinmindthatthepurposeofthisapplicationistoinstruct.Useitwithcaution.Itlacksextensiveerrorhandling,anditmaybogdownwhenthedatasetislarge.
Pleasesendusyourcommentaboutthispage
![Page 120: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/120.jpg)
StoringBlockAttributePositionsinanOracleSpatialDatabase
OracleSpatialData(Overview)RelatedSamples
The"StoringBlockAttributePositions"sampleisanObjectARXprojectlocatedinMapSamples\AcMapFlatOrclAttrPosinAutoCADMap3DObjectARXinstallations.
ClassesHighlighted
IthighlightsthefollowingOracleSpatialclasses.
AcMapOSEConnectionAcMapOSEImportReactorAcMapOSEExportReactorAcMapOSEObject
Thefollowingclassesareincludedalso,buttheiruseislessextensive.
AcMapOSEImportAcMapOSEExportAcMapOSEQueryAcMapOSEConnectionReactor
Commandsimplemented
TheprojectcreatesanrxmodulewhichletstheuserchangeattributepositionsinaprojectdrawingandpreservethesechangesinanOracledatabase.Itexposesthefollowingcommands.
APEXPORTexportstheactiveprojectdrawingtoanOracledatabase,includinginformationaboutattributepositions.
APIMPORTimportsOracleSpatialdatatotheactiveprojectdrawing,restoringattributestotheiroriginalpositions.
Note
![Page 121: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/121.jpg)
ThesampleassumesthatfeaturesarealreadydefinedcompletelyusingourMAPOSEADMINcommand.
Keepinmindthatthepurposeofthisapplicationistoinstruct.Useitwithcaution.Itlacksextensiveerrorhandling,anditmaybogdownwhenthedatasetislarge.
Pleasesendusyourcommentaboutthispage
![Page 122: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/122.jpg)
Topology
AnAutoCADMap3Dtopologyisasetofobjectsandtheobjectdatathatdefinestherelationshipsbetweentheobjects.
Topicsinthissection
TopologyDetail
Pleasesendusyourcommentaboutthispage
![Page 123: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/123.jpg)
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.
![Page 124: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/124.jpg)
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.
![Page 125: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/125.jpg)
//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;
![Page 126: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/126.jpg)
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.
...
}
![Page 127: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/127.jpg)
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.
![Page 128: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/128.jpg)
//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
![Page 129: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/129.jpg)
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.
}
![Page 130: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/130.jpg)
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)
![Page 131: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/131.jpg)
{
//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()
![Page 132: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/132.jpg)
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.
![Page 133: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/133.jpg)
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);
![Page 134: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/134.jpg)
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;
![Page 135: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/135.jpg)
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
![Page 136: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/136.jpg)
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.
![Page 137: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/137.jpg)
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.
![Page 138: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/138.jpg)
}
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;
![Page 139: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/139.jpg)
//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>AutoCADMap3DHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>Topology(SpatialAnalysis).
![Page 140: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/140.jpg)
ForatopologytutorialinAutoCADMap3D,chooseHelp>Tutorials>Contentstab,andthenchoose"UsingTopologyandSpatialAnalysis".
ForinformationaboutobjectdatainAutoCADMap3D,chooseHelp>AutoCADMap3DHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>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
![Page 141: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/141.jpg)
AcMapNetAnalysisParametersClass
AcMapMarkerStylesClass
AcMapTopoElementPtrArrayTemplateClass
AcMapObjectPtrArrayClass
AcMapFullEdgePtrArrayClass
AcMapHalfEdgePtrArrayClass
AcMapNodePtrArrayClass
AcMapPolygonPtrArrayClass
AcMapRingPtrArrayClass
AcMapTopologyManagerNamespace
AcMapObjectDataFieldGlobalStruct
AcMapObjectDataTableGlobalStruct
ETopologyMarkTypeGlobalEnum
ETopologyTypeGlobalEnum
Pleasesendusyourcommentaboutthispage
![Page 142: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/142.jpg)
Centroids
Creatingcentroidsmovesattacheddatafromtheperimetersofmpolygonsandclosedpolylinestotheircentroidssothatthedataisnotlostwhentopologiesarecreated.
Topicsinthissection
CreatingCentroids
Pleasesendusyourcommentaboutthispage
![Page 143: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/143.jpg)
CreatingCentroids
Youmustcreatecentroidsformpolygonsandclosedpolylinesbeforebuildingatopologywiththem.
AclosedpolylineisapolygonproducedbythePOLYGONcommand.
CreatingCentroids
OtherInformationSources
CreatingCentroidsSamplesCreatingCentroidsNamespace
CreatingCentroids
UsetheCreateCentroids()(twoforms)functionsintheAcMapUtilitiesnamespacetocreatecentroids.
Forcentroid-creationsource-codesamples,seeCreatingCentroidsSamples.
Backtotop
OtherInformationSources
FormoreinformationaboutcreatingcentroidsinAutoCADMap3D,chooseHelp>AutodeskMapHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>Topology(SpatialAnalysis)>EditingTopologies>CreatingCentroidsforPolygons.
Backtotop
CreatingCentroidsSamples
Toviewcodesamplesofcentroid-creationfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMap
![Page 144: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/144.jpg)
Samples\CreateCentroid.
Backtotop
CreatingCentroidsNamespace
Toviewthecentroid-creationnamespace,clickthefollowinglink:
AcMapUtilitiesNamespace
Backtotop
Pleasesendusyourcommentaboutthispage
![Page 145: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/145.jpg)
DrawingCleanup
Youmustcleandrawingobjectsbeforebuildingatopologywiththem.
Topicsinthissection
DrawingCleanupDetails
Pleasesendusyourcommentaboutthispage
![Page 146: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/146.jpg)
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.
![Page 147: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/147.jpg)
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);
![Page 148: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/148.jpg)
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
![Page 149: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/149.jpg)
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
![Page 150: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/150.jpg)
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);
![Page 151: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/151.jpg)
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
![Page 152: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/152.jpg)
Annotation
UseAutoCADMap'sannotationfeaturetoindicatetextualvaluesonadrawingobject.
Thesetextualvaluesmightbeattributes(suchasobjectdata),displayproperties(suchasalineweight),orgeometricvalues(suchasthelinedirection).Inaddition,youcanaddgraphics,suchasarrows,statictext,orothergeometry,toyourannotationbyusingstandardAutoCADdrawingcommands.AnnotationfunctionsareavailableintheAcMapAnnotationManagernamespace.SeealsoOtherInformationSources.
Topicsinthissection
AnnotationDetails
Pleasesendusyourcommentaboutthispage
![Page 153: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/153.jpg)
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))
![Page 154: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/154.jpg)
{
//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);
![Page 155: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/155.jpg)
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);
}
![Page 156: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/156.jpg)
//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)
{
![Page 157: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/157.jpg)
//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
![Page 158: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/158.jpg)
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
![Page 159: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/159.jpg)
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>AutodeskMapHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>Annotation.
ForanannotationtutorialinAutoCADMap3D,chooseHelp>Tutorials>Contentstab,andthenchoose"AddingAnnotationsto
![Page 160: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/160.jpg)
Objects".
FormoreinformationaboutexpressionsinAutoCADMap3D,chooseHelp>AutodeskMapHelp>Contentstab(orpressF1),andthennavigatetoExpressionEvaluator.
Backtotop
AnnotationSamples
Toviewcodesamplesofannotationfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\Annotation.
Backtotop
AnnotationNamespace
Toviewtheannotationnamespace,clickthefollowinglink:
AcMapAnnotationManagerNamespace
Pleasesendusyourcommentaboutthispage
![Page 161: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/161.jpg)
DisplayManager
Managesthedisplayofselectedobjectsinadrawingforthemingorhighlighting.
Formoreinformation,see
DisplayManagerinObjectARXReferenceHelp.
DisplayManagersamplecode,whichislocatedintheMapSamples\DisplayManagementfolderofAutoCADMap3DObjectARXinstallations.
DisplayManagerintheUIdocumentation,AutoCADMap3DHelp.
Pleasesendusyourcommentaboutthispage
![Page 162: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/162.jpg)
UserManagement
TheAutoCADMap3Duser-managementfeatureprovidesuser-andsession-managementtoolsforsystemadministrators.
Topicsinthissection
UserManagementDetail
Pleasesendusyourcommentaboutthispage
![Page 163: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/163.jpg)
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()
![Page 164: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/164.jpg)
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>AutodeskMapHelp>Contentstab(orpressF1),andthennavigatetoUsingAutoCADMap3D(byfeature)>SettingUpAutoCADMap3DDrawings>SettingOptions>SettingUpUsers.
UserManagementSamples
Toviewcodesamplesofuser-managementfunctions,opentheSamplesfolderinyourAutoCADMap3DObjectARXinstallationandnavigatetoMapSamples\UserManager.
![Page 165: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/165.jpg)
UserManagementClassesandGlobals
Toviewtheuser-managementclassesandglobals,clickthefollowinglinks:
AcMapSessionClassAcMapGetSession()GlobalFunction
Pleasesendusyourcommentaboutthispage
![Page 166: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/166.jpg)
MapPlottingandPublishing
ThistopicdescribesplottingandpublishingmapsusingMapBookclasses.
Topicsinthissection
MapPlottingandPublishingDetail
Pleasesendusyourcommentaboutthispage
![Page 167: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/167.jpg)
MapPlottingandPublishingDetail
Althoughtheglobal-functionAPIformapplottingremainsinplace,andexistingcodethatisbasedonitisstillvalid,newdevelopmentforplottingmapsshoulduseMapBookclasses.
Formoreinformation,see
MapBookinAutoCADMap3DObjectARXReferenceHelp.
MapBooksamplecode,whichislocatedintheMapSamples\PlottingfolderofAutodeskMapObjectARXinstallations.
MapBookintheUIdocumentation,AutoCADMap3DHelp.
Pleasesendusyourcommentaboutthispage
![Page 168: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/168.jpg)
ManagedWrapperClasses
ObjectARXpresentedasmanagedC++.
Topicsinthissection
ManagedWrapperClassesDetail
Pleasesendusyourcommentaboutthispage
![Page 169: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/169.jpg)
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;
![Page 170: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/170.jpg)
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
![Page 171: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/171.jpg)
Notes,Tips,andWarnings
Topicsinthissection
Colors
Pleasesendusyourcommentaboutthispage
![Page 172: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/172.jpg)
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
![Page 173: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/173.jpg)
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<>"red,green"islogicallyequivalentto(color<>"red")AND(color<>"green").
![Page 174: Before You Begin - Documentation & Help · Before You Begin AutoCAD Map 3D ObjectARX Developer's Guide describes how to use ObjectARX classes to automate and extend AutoCAD Map 3D](https://reader030.vdocuments.us/reader030/viewer/2022040214/5eb7aba4b3568150522bd86b/html5/thumbnails/174.jpg)
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