美文网首页
Finding the Position of a Compon

Finding the Position of a Compon

作者: 锦囊喵 | 来源:发表于2022-02-06 18:39 被阅读0次

    This example shows a function that finds the matrix that describes
    the position of an assembly component in its parent assembly.

    /*====================================================================*\
    Function : UserAsmcompTransfGet()
    Purpose : Find the transformation matrix of the specified component
    \*====================================================================*/
    int UserAsmcompTransfGet()
    {
     ProError status;
     ProMdl model;
     int nb_sel, i;
     ProMatrix matrix;
     ProAsmcomppath comp_path;
     ProIdTable comp_id_table;
     ProSelection *sel_list,selection;
     ProModelitem sel_obj;
     ProFeature feature;
     ProFeattypeftype;
     FILE *fp_out=NULL;
     ProName w_name, wfile_name;
     ProCharName name;
     status = ProSelect ("prt_or_asm",1,NULL,NULL,NULL,NULL,
     &sel_list,&nb_sel);
     ERROR_CHECK("UserAsmcompTransfGet","ProSelect",status);
     if (status == PRO_TK_NO_ERROR)
     {
     if (nb_sel > 0)
     {
     status = ProSelectionModelitemGet (sel_list[0],&sel_obj);
     ERROR_CHECK("UserAsmcompTransfGet","ProSelectionModelitemGet",
     status);
     status = ProSelectionHighlight (sel_list[0],PRO_COLOR_ERROR);
     ERROR_CHECK("UserAsmcompTransfGet","ProSelectionHighlight",
     status);
     status = ProSelectionAsmcomppathGet(sel_list[0],&comp_path);
     ERROR_CHECK("UserAsmcompTransfGet","ProSelectionAsmcomppathGet",
     status);
     if (status != PRO_TK_NO_ERROR) return (PRO_TK_GENERAL_ERROR);
     status = ProAsmcomppathTrfGet (&comp_path,PRO_B_TRUE,matrix);
     ERROR_CHECK("UserAsmcompTransfGet","ProAsmcomppathTrfGet",
     status);
     if (status != PRO_TK_NO_ERROR) return (PRO_TK_GENERAL_ERROR);
     status = ProAsmcomppathMdlGet(&comp_path,&model);
     ERROR_CHECK("UserAsmcompTransfGet","ProAsmcomppathMdlGet",
     status);
     if (status != PRO_TK_NO_ERROR) return (PRO_TK_GENERAL_ERROR);
    
    ProMdlNameGet(model,w_name);
     ProWstringToString(name,w_name);
     fp_out = PTApplsUnicodeFopen("rptfile.txt", "w");
     ProTKFprintf(fp_out, " ------ Component Location ------ \n\n");
     ProTKFprintf(fp_out, "Component name : %s\n\n",name);
     ProTKFprintf(fp_out, "Matrix :\n\n");
     for (i=0 ; i<4 ; i++)
     ProTKFprintf(fp_out, "%f\t%f\t%f\t%f\n",
     matrix[i][0],matrix[i][1],
     matrix[i][2],matrix[i][3]);
     fclose(fp_out);
     ProStringToWstring(w_name,"rptfile.txt");
     status = ProInfoWindowDisplay (w_name,NULL,NULL);
     ERROR_CHECK("UserAsmcompTransfGet","ProInfoWindowDisplay",
     status);
     if (status != PRO_TK_NO_ERROR) return (-1);
     }
     }
     return (PRO_TK_NO_ERROR);
    }
    

    相关文章

      网友评论

          本文标题:Finding the Position of a Compon

          本文链接:https://www.haomeiwen.com/subject/ajoukrtx.html