/*====================================================================*\ FILE : TestSkelet.c PURPOSE : Test skeletom models supporting. HISTORY.. DATE BUILD AUTHOR MODIFICATIONS 10-Apr-98 I-01-01 Akula $$1 Created 01-Jun-99 I-03-11 mka $$2 Delete unused variable \*====================================================================*/ /*--------------------------------------------------------------------*\ Pro/TOOLKIT includes \*--------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*--------------------------------------------------------------------*\ Application includes \*--------------------------------------------------------------------*/ #include "TestError.h" #include "UtilMenu.h" /*====================================================================*\ Function : ProTestMdlGet() Purpose : \*====================================================================*/ ProError ProTestMdlGet(ProMdl * mdl) { ProError err; wchar_t wname[PRO_LINE_SIZE]; char cname [PRO_LINE_SIZE]; char * c_pnt; ProMdlType type = PRO_PART; ProUtilMsgPrint("gen", "TEST %0s", "Enter model name (.prt or .asm) : "); if(!ProUtilStringGet(wname, NULL, PRO_LINE_SIZE)) { *mdl = NULL; return PRO_TK_NO_ERROR; } ProWstringToString(cname, wname); if ((c_pnt = strstr (cname , ".asm")) != NULL) type = PRO_MDL_ASSEMBLY; else if ((c_pnt = strstr (cname , ".prt")) != NULL) type = PRO_MDL_PART; else return PRO_TK_BAD_INPUTS; *c_pnt = '\0'; ProStringToWstring(wname, cname); err = ProMdlRetrieve ( wname, type, mdl); TEST_CALL_REPORT("ProMdlRetrieve()", "ProTestMdlGet()", err, err != PRO_TK_NO_ERROR); return err; } /*====================================================================*\ Function : ProTestSkeletonCreate() Purpose : \*====================================================================*/ ProError ProTestSkeletonCreate (ProAssembly curent_ass, int action) { ProMdl template; ProMdl skel; ProError err; wchar_t wname[PRO_LINE_SIZE]; /*--------*/ ProModelitem mi; ProName nm; err = ProTestMdlGet (& template); if (err != PRO_TK_NO_ERROR) return PRO_TK_NO_ERROR; ProUtilMsgPrint("gen", "TEST %0s", "Enter a skeleton name : "); if(!ProUtilStringGet(wname, NULL, PRO_LINE_SIZE)) { return PRO_TK_NO_ERROR; } err = ProMdlToModelitem (template, &mi); err = ProMdlNameGet (template, nm); err = ProMdlNameGet (curent_ass, nm); err = ProAsmSkeletonCreate (curent_ass, wname, template, &skel); TEST_CALL_REPORT("ProAsmSkeletonCreate()", "ProTestSkeletonCreate()", err, err != PRO_TK_NO_ERROR); return err; } /*====================================================================*\ Function : ProTestCopyCreate() Purpose : \*====================================================================*/ ProError ProTestCopyCreate (ProAssembly curent_ass, int action) { ProMdl template; ProMdlType comp_type; ProBoolean leave_unpl; ProAsmcomp new_comp; ProError err; wchar_t wname[PRO_LINE_SIZE]; wchar_t * wnames [3]; int i, dummy; err = ProTestMdlGet (& template); if (err != PRO_TK_NO_ERROR) return PRO_TK_NO_ERROR; ProUtilMsgPrint("gen", "TEST %0s", "Enter a component name : "); if(!ProUtilStringGet(wname, NULL, PRO_LINE_SIZE)) { return PRO_TK_NO_ERROR; } for (i=0; i<3; i++) { wnames[i] = (wchar_t*)calloc(PRO_NAME_SIZE, sizeof(wchar_t)); } ProStringToWstring(wnames[0], "Part"); ProStringToWstring(wnames[1], "Assembly"); ProStringToWstring(wnames[2], ""); err = ProMenuFromStringsRegister("Model Type", NULL, wnames, NULL, NULL, &dummy); ProMenubuttonActionSet( "Model Type", "Part", (ProMenubuttonAction)ProUtilAssign, (ProAppData)&comp_type , PRO_PART); ProMenubuttonActionSet( "Model Type", "Assembly", (ProMenubuttonAction)ProUtilAssign,(ProAppData)&comp_type , PRO_ASSEMBLY); ProMenubuttonActionSet( "Model Type", "Model Type", (ProMenubuttonAction)ProMenuDelete, NULL, 0); ProMenuCreate(PROMENUTYPE_MAIN, "Model Type", NULL); ProMenuProcess("Model Type", &i); ProStringToWstring(wnames[0], "Unplaced"); ProStringToWstring(wnames[1], "Default"); err = ProMenuFromStringsRegister("Placment Type", NULL, wnames, NULL, NULL, &dummy); ProMenubuttonActionSet( "Placment Type", "Unplaced", (ProMenubuttonAction)ProUtilAssign, (ProAppData)&leave_unpl , PRO_B_TRUE); ProMenubuttonActionSet( "Placment Type", "Default", (ProMenubuttonAction)ProUtilAssign,(ProAppData)&leave_unpl , PRO_B_FALSE); ProMenubuttonActionSet( "Placment Type", "Placment Type", (ProMenubuttonAction)ProMenuDelete, NULL, 0); ProMenuCreate(PROMENUTYPE_MAIN, "Placment Type", NULL); ProMenuProcess("Placment Type", &i); err = ProAsmcompCreateCopy (curent_ass, wname, comp_type, template, leave_unpl, &new_comp); TEST_CALL_REPORT("ProAsmcompCreateCopy()","ProTestCopyCreate()", err, err != PRO_TK_NO_ERROR); for (i=0; i<3; i++) { free (wnames [i]); } return err; } /*====================================================================*\ Function : ProTestSkelCopyCreate() Purpose : \*====================================================================*/ int ProTestSkelCopyCreate(ProAssembly curent_ass) { char * cnames [] = { "Create skeleton", "Create Copy", "" }; wchar_t * wnames [3]; int i, dummy; ProError err; for (i=0; i<3; i++) { wnames[i] = (wchar_t*)calloc(PRO_NAME_SIZE, sizeof(wchar_t)); ProStringToWstring(wnames[i], cnames[i]); } err = ProMenuFromStringsRegister("TkAsmcompCreate", NULL, wnames, NULL, NULL, &dummy); TEST_CALL_REPORT("ProMenuFromStringsRegister()", "ProTestSkelCopyCreate()", err, err != PRO_TK_NO_ERROR); for (i=0; i<3; i++) { free (wnames [i]); } ProMenubuttonActionSet( "TkAsmcompCreate", "Create skeleton", (ProMenubuttonAction)ProTestSkeletonCreate, curent_ass, 0); ProMenubuttonActionSet( "TkAsmcompCreate", "Create Copy", (ProMenubuttonAction)ProTestCopyCreate, curent_ass, 0); ProMenubuttonActionSet( "TkAsmcompCreate", "TkAsmcompCreate", (ProMenubuttonAction)ProMenuDelete, NULL, 0); ProMenuCreate(PROMENUTYPE_MAIN, "TkAsmcompCreate", NULL); ProMenuProcess("TkAsmcompCreate", &i); return (0); } /*====================================================================*\ Function : ProTestAsmSkeletonAdd() Purpose : \*====================================================================*/ ProError ProTestAsmSkeletonAdd (ProAssembly curent_ass, int action) { ProMdl template; ProError err; err = ProTestMdlGet (& template); if (err != PRO_TK_NO_ERROR ||template == NULL ) return PRO_TK_NO_ERROR; err = ProAsmSkeletonAdd (curent_ass, template); TEST_CALL_REPORT("ProAssmSkeletonAdd()", "ProTestAsmSkeletonAdd()", err, err != PRO_TK_NO_ERROR); return err; } /*====================================================================*\ Function : ProTestAsmSkeletonDelete() Purpose : \*====================================================================*/ ProError ProTestAsmSkeletonDelete (ProAssembly curent_ass, int action) { ProError err; err = ProAsmSkeletonDelete (curent_ass); TEST_CALL_REPORT("ProAsmSkeletonDelete()", "ProTestAsmSkeletonDelete()", err, err != PRO_TK_NO_ERROR); return err; } /*====================================================================*\ Function : ProTestAsmSkeletonSave() Purpose : \*====================================================================*/ ProError ProTestAsmSkeletonSave (ProAssembly curent_ass, int action) { ProMdl skeleton; ProError err; err = ProAsmSkeletonGet (curent_ass, &skeleton); TEST_CALL_REPORT("ProAsmSkeletonGet()", "ProTestAsmSkeletonSave()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) return err; err = ProMdlSave (skeleton); TEST_CALL_REPORT("ProMdlSave()", "ProTestAsmSkeletonSave()", err, err != PRO_TK_NO_ERROR); return err; } /*====================================================================*\ Function : ProTestAsmcompFill() Purpose : \*====================================================================*/ ProError ProTestAsmcompFill (ProAssembly curent_ass, int action) { ProError ProUtilAsmcompSelect(ProAsmcomp *p_asmcomp); ProMdl template; ProError err; ProAsmcomp asmcomp; err = ProTestMdlGet (& template); if (err != PRO_TK_NO_ERROR ) return PRO_TK_NO_ERROR; err = ProUtilAsmcompSelect (&asmcomp); if (err != PRO_TK_NO_ERROR) return PRO_TK_NO_ERROR; err = ProAsmcompFillFromMdl (&asmcomp, template); TEST_CALL_REPORT("ProAsmcompFillFromMdl()", "ProTestAsmSkeletonSave()", err, err != PRO_TK_NO_ERROR); return err; } /*====================================================================*\ Function : ProTestCompSkelReplace() Purpose : \*====================================================================*/ int ProTestCompSkelReplace (ProAssembly curent_ass) { char * cnames [] = { "Skeleton Add", "Skeleton Delete", "Skeleton Save", "Fill from Model", "" }; wchar_t * wnames [sizeof (cnames)/sizeof (char*)]; int i, dummy; ProError err; for (i=0; i