2015-12-17
1 //gets all entity IDs on the specified layer2Acdbobjectidarray Getallentityid (Consttchar*layername)3 {4 Acdbobjectidarray Entids;5 BOOLBfilterlayer =false;6 Acdbobjectid Layerid;7 //gets the specified Layer object ID8 if(LayerName! =NULL)9 {TenAcdblayertable *PLAYERTBL =NULL; OneAcdbhostapplicationservices ()->workingdatabase ()getsymboltable (PLAYERTBL, acdb::kforread); A if(!playertbl->Has (layername)) - { -Playertbl->close (); the returnEntids; - } -Playertbl->getAt (LayerName, Layerid); -Playertbl->close (); +Bfilterlayer =true; - } + //Get block Table AAcdbblocktable *PBLKTBL =NULL; atAcdbhostapplicationservices ()->workingdatabase ()getsymboltable (PBLKTBL, acdb::kforread); - //Block table record -Acdbblocktablerecord *PBLKTBLRCD =NULL; -Pblktbl->getAt (Acdb_model_space, PBLKTBLRCD, acdb::kforread); -Pblktbl->close (); - //Create a walker to access each entity in the model space in turn inAcdbblocktablerecorditerator *it =NULL; -Pblktblrcd->Newiterator (it); to for(It->start ();!it->done (); it->Step ()) + { -Acdbentity *pent =NULL; theAcad::errorstatus es = it->getentity (pent, acdb::kforread); * if(es = =Acad::eok) $ {Panax Notoginseng if(Bfilterlayer)//Filter Layers - { the if(Pent->layerid () = =Layerid) + { AEntids.append (pent->objectId ()); the } + } - Else $ { $ //Entids.append (Pent->objectid ()); -Pent->close (); - } the } - }Wuyi Deleteit; thePblktblrcd->close (); - returnEntids; Wu}
Objectarx get all entity IDs on the specified layer