只遍历有参对象Line的方法
theSession->ListingWindow()->Open();
///遍历方式
Features::Feature *fcList;
std::vector<NXObject *> entitiesArray;
Features::FeatureCollection *fc=workPart->Features();//迭代
Features::FeatureCollection::iterator itr=fc->begin();//获得第一个特征
Line *line3=NULL;
std::vector<tag_t> lineNum;
char msg [111];
for (;itr!=fc->end();++itr) //循环获得所有特征
{
fcList=(*itr); //获得特征赋值给fcList
NXString featType = NULL;
featType = fcList->FeatureType();
theSession->ListingWindow()->WriteLine(fcList->FeatureType());
if(!strcmp(featType.GetLocaleText(),"LINE"))
{
lineNum.push_back(fcList->Tag());
entitiesArray = fcList->GetEntities(); //GetEntities方法,实体下0对象,Lineg下1对对象,基准下7对象,点集下对象最多
int a;
a = entitiesArray.size();
sprintf(msg,"%d",a);
theSession->ListingWindow()->WriteLine(msg);
//line3 = dynamic_cast<Line*>(entitiesArray[0]);
}
}
sprintf(msg,"总数量%d",lineNum.size());
theSession->ListingWindow()->WriteLine(msg);
sprintf(msg,"%d",lineNum[0]);
theSession->ListingWindow()->WriteLine(msg);
sprintf(msg,"%d",lineNum[2]);
theSession->ListingWindow()->WriteLine(msg);