|
使用ProSolidFeatVisit函数搜索Feature。
int AsmCompPathAction(uiCmdCmdId command, uiCmdValue *p_value, void *p_push_command_data) {
ProError pro_error = PRO_TK_NO_ERROR;
ProAssembly pro_assy = NULL;
//Get the current model
pro_error = ProMdlCurrentGet((ProMdl*)&pro_assy);
//Visit the assembly components
pro_error = ProSolidFeatVisit((ProSolid)pro_assy,
(ProFeatureVisitAction)VisitAction,
(ProFeatureFilterAction)FilterAction,
&pro_assy);
return 0;
}
ProError VisitAction(ProFeature* p_feature, ProError status, ProAppData app_data) {
ProError pro_error = PRO_TK_NO_ERROR;
ProMdl pro_mdl = NULL;
ProAssembly *pro_assy = (ProAssembly*)app_data;
ProIdTable pro_IdTable;
ProAsmcomppath pro_asmCompPath;
ProMatrix pro_mtx;
//Get the model from the component
pro_error = ProAsmcompMdlGet((ProAsmcomp*)p_feature, &pro_mdl);
pro_IdTable[0] = p_feature->id;
pro_IdTable[1] = -1;
//Initialize the assembly component path
pro_error = ProAsmcomppathInit((ProSolid)*pro_assy, pro_IdTable, 1, &pro_asmCompPath);
//Get the transformation matrix from the member to the assembly
pro_error = ProAsmcomppathTrfGet(&pro_asmCompPath, PRO_B_TRUE, pro_mtx);
//Print the matrix
printf("%f %f %f %f\n", pro_mtx[0][0], pro_mtx[0][1], pro_mtx[0][2], pro_mtx[0][3]);
printf("%f %f %f %f\n", pro_mtx[1][0], pro_mtx[1][1], pro_mtx[1][2], pro_mtx[1][3]);
printf("%f %f %f %f\n", pro_mtx[2][0], pro_mtx[2][1], pro_mtx[2][2], pro_mtx[2][3]);
printf("%f %f %f %f\n\n", pro_mtx[3][0], pro_mtx[3][1], pro_mtx[3][2], pro_mtx[3][3]);
return PRO_TK_NO_ERROR;
}
ProError FilterAction(ProFeature* p_feature, ProAppData app_data) {
ProError pro_error = PRO_TK_NO_ERROR;
ProFeattype pro_featType = -1;
ProFeatStatus pro_featStatus;
//Get the type of the feature
pro_error = ProFeatureTypeGet(p_feature, &pro_featType);
if(pro_featType != PRO_FEAT_COMPONENT)
return PRO_TK_CONTINUE;
//Get the feature status
pro_error = ProFeatureStatusGet(p_feature, &pro_featStatus);
if(pro_featStatus == PRO_FEAT_INVALID ||
pro_featStatus == PRO_FEAT_INACTIVE ||
pro_featStatus == PRO_FEAT_FAMTAB_SUPPRESSED ||
pro_featStatus == PRO_FEAT_SIMP_REP_SUPPRESSED ||
pro_featStatus == PRO_FEAT_PROG_SUPPRESSED ||
pro_featStatus == PRO_FEAT_SUPPRESSED)
return PRO_TK_CONTINUE;
return PRO_TK_NO_ERROR;
} |
|