您的位置:首页 > 其它

VS2010 Creo2.0 删除零件

2015-06-23 14:56 274 查看
构造要删除零件的特征del_feat

ProSelection *p_sel = NULL;
int n_sel;
ProMdl mdl;
ProModelitem sel_item;
ProFeature feature, p_feat_handle;
ProMdl p_owner;

ProAsmcomppath path;
ProMdlCurrentGet(&mdl);
std::vector<ProFeature> featls;
err = ProSolidFeatVisit((ProSolid)mdl, ProFeatureVisitAction_f10, ProFeatureFilterAction_f10, &featls);

err = ProSelect((char*)"prt_or_asm", 1, NULL,NULL, NULL, NULL, &p_sel, &n_sel);
if (err != PRO_TK_NO_ERROR || n_sel < 1)	return;
err = ProSelectionAsmcomppathGet(p_sel[0], &path);
if (err != PRO_TK_NO_ERROR)	return;

ProAsmcomppath father_path = path;
father_path.table_num--;
ProMdl father_mdl;
err = ProAsmcomppathMdlGet(&father_path,&father_mdl);
ProFeature del_feat;
del_feat.owner = father_mdl;
del_feat.id = path.comp_id_table[path.table_num-1];
del_feat.type = PRO_FEATURE;
featureDel(&del_feat);


ProFeatureDelete函数

ProError featureDel(ProFeature *feat)

ProError err = PRO_TK_NO_ERROR;
int featsDelids[1];
featsDelids[0]=feat->id;

ProFeatureDeleteOptions delOps[]={PRO_FEAT_DELETE_NO_OPTS};
err=ProFeatureDelete((ProSolid)feat->owner,featsDelids,1,delOps,1);
if (err != PRO_TK_NO_ERROR)	return err;
return err;


动作函数

ProError ProFeatureVisitAction_f10(ProFeature* p_feature, ProError status, ProAppData app_data);

ProError ProFeatureVisitAction_f10(ProFeature* p_feature, ProError status, ProAppData app_data)
{
std::vector<ProFeature>* pls = (std::vector<ProFeature>*)app_data;

ProMdl p_mdl_handle;
ProError err;
ProFeattype p_type;
ProMdlType ptype;
ProBoolean p_is_auto_round_member;
err = ProFeatureTypeGet(p_feature, &p_type);

if (p_type == PRO_FEAT_COMPONENT)
{
ProAsmcompMdlGet((ProAsmcomp*)p_feature, &p_mdl_handle);
ProMdlTypeGet(p_mdl_handle, &ptype);
if (ptype == PRO_MDL_ASSEMBLY)
{
ProSolidFeatVisit((ProSolid)p_mdl_handle, ProFeatureVisitAction_f10, ProFeatureFilterAction_f10, app_data);
}

}
pls->push_back(*p_feature);
return PRO_TK_NO_ERROR;
}


过滤函数

ProError ProFeatureFilterAction_f10(ProFeature* p_parameter, ProAppData app_data);
ProError ProFeatureFilterAction_f10(ProFeature* p_parameter, ProAppData app_data)
{
return PRO_TK_NO_ERROR;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: