Query Sample Code
Query Sample Code
AcMapProject *pProj = NULL;// Create a new branch objectAcMapQueryBranch *pRootBranch = NULL;pRootBranch = new AcMapQueryBranch(AcMap::kOperatorOr);// Create a new property conditionconst char *pcValuePC = "Layer1";AcMapPropertyCondition *pPropertyCondition = NULL;pPropertyCondition = new AcMapPropertyCondition(AcMap::kOperatorOr,AcMap::kLayer,AcMap::kCondEq,pcValuePC);AcMapSession *pMapSession = NULL;AcMapQuery *pNewQuery = NULL;// Get the session objectpMapSession = AcMapGetSession();if (pMapSession){// Get the currently active projectif (pMapSession->GetProject(pProj) == AcMap::kOk){// Create a new query objectif ( pProj->CreateQuery(pNewQuery,Adesk::kFalse) == AcMap::kOk ){// Create a new property conditionconst char *pcValuePC = "Layer1";AcMapPropertyCondition *pPropertyCondition = NULL;pPropertyCondition = new AcMapPropertyCondition(AcMap::kOperatorOr,AcMap::kLayer,AcMap::kCondEq,pcValuePC);// Create a new branch objectAcMapQueryBranch *pBranch = NULL;pBranch = new AcMapQueryBranch();// Append the condition to the branchpBranch->AppendOperand(pPropertyCondition);// Define the branch in the queryif (pNewQuery->Define(pBranch) == AcMap::kOk){// Run the query.pNewQuery->Run();}// Clean updelete pPropertyCondition;delete pBranch;delete pNewQuery;} // if (pProj->CreateQuery} // if (pMapSession->GetProject} // if (pMapSession)