ProSrftype type;
ProError UserGeomitemVisitAct(ProGeomitem* geomitem,ProError status,ProAppData data)
{
ProSurface surface;
ProSrftype surf_type;
status=ProGeomitemToSurface(geomitem,&surface);
status=ProSurfaceTypeGet(surface,&surf_type);
if (type==surf_type)
{
vector<ProGeomitem>* pf=(vector<ProGeomitem>*)data;
pf->push_back(*geomitem);
}
return PRO_TK_NO_ERROR;
}
ProError UserFeatureVisitAct(ProFeature* p_feature,ProError status,ProAppData data)
{
//遍历特征下的几何项
status=ProFeatureGeomitemVisit(p_feature,PRO_TYPE_UNUSED,(ProGeomitemAction)UserGeomitemVisitAct,NULL,&Geomitem);
if (PRO_TK_NO_ERROR!=status)
{
return status;
}
return PRO_TK_NO_ERROR;
}
void CSearchMdl::OnBnClickedBtnSearchMdlByGeomItem()
{
// TODO: 在此添加控件通知处理程序代码
ProError status;
ProName name;
ProStringToWstring(name,"D:\\demo\\test");
ProPath *file_list,*dir_list;
status=ProArrayAlloc(0,sizeof(ProPath),1,(ProArray*)&file_list);
status=ProArrayAlloc(0,sizeof(ProPath),1,(ProArray*)&dir_list);
status=ProFilesList(name,L"*.prt",PRO_FILE_LIST_LATEST,&file_list,&dir_list);
if (PRO_TK_NO_ERROR!=status)
{
return;
}
int size=0;
status=ProArraySizeGet((ProArray)file_list,&size);
CString strWeb;
int nSel;
//获取组合框控件的列表中选项索引
nSel=m_comboWeb.GetCurSel();
//根据选中项索引获取该字符串
m_comboWeb.GetLBText(nSel,strWeb);
if (_T("圆柱面")==strWeb)
type=PRO_SRF_CYL;
else if(_T("旋转面")==strWeb)
type=PRO_SRF_SPL;
else
type=PRO_SRF_PLANE;
//清空列表控件
m_GeomMdlList.DeleteAllItems();
ProMdl mdl;
ProName mdl_name;
vector<ProFeature> p_feat;
for (int i=0;i<size;i++)
{
//清空向量
Geomitem.clear();
ProMdlLoad(file_list[i],PRO_MDL_PART,PRO_B_FALSE,&mdl);
ProMdlDisplay(mdl);
//遍历指定实体的所有特征
status=ProSolidFeatVisit((ProSolid)mdl,(ProFeatureVisitAction)UserFeatureVisitAct,NULL,(ProAppData)&p_feat);
if (Geomitem.size()!=0)
{
status=ProMdlNameGet(mdl,mdl_name);
m_GeomMdlList.InsertItem(0,mdl_name);
}
}
}
运行结果: