找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 7700|回复: 0

[转贴] 取出assembly的转换矩阵

[复制链接]

2

主题

8

回帖

0

威望

实习生

积分
11
发表于 2012-7-20 13:37 | 显示全部楼层 |阅读模式
使用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;
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站为非营利性站点,部分资源为网友搜集或发布,仅供学习和研究使用,如用于商业用途,请购买正版。站内所发布的资源,如有侵犯你的权益,请发邮件联系我们,本站将立即改正或删除。

手机版|小黑屋|野火论坛(©2007~2024) ( 苏ICP备11036728号-2 )苏公网安备 32039102000103号|站长QQ28016688

GMT+8, 2024-11-22 17:37 , Processed in 0.128306 second(s), 20 queries .

快速回复 返回顶部 返回列表