Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hi everyone, I've been having a big problem trying to display a model in creo with TOOLKIT on my computer.Following is my programm:
#include "stdafx.h"
#include "ProToolkit.h"
#include "ProCore.h"
#include "ProMdl.h"
#include "ProUtil.h"
#include "ProWindows.h"
#include <ProTKRunTime.h>
int main()
{
char *a_char_ptr;
a_char_ptr= "C:\\Program Files\\PTC\\Creo 3.0\\M010\\Parametric\\bin\\parametric.bat";
ProError i= ProEngineerStart(a_char_ptr,"");
ProError status;
ProPath Mdlpath;
ProType MdlType;
ProMdl *Mdl;
ProMdlName MdlName;
int *w_id;
ProStringToWstring(Mdlpath,"C:\\Users\\fsd_proe\\Documents\\bauteil1.prt");
status =ProMdlFiletypeLoad(Mdlpath,PRO_MDLFILE_UNUSED,PRO_B_FALSE, Mdl);
status=ProMdlTypeGet(Mdl,(ProMdlType*)&MdlType);
status=ProMdlMdlnameGet(Mdl,MdlName);
status= ProObjectwindowMdlnameCreate(MdlName,MdlType,w_id);
status=ProMdlDisplay(Mdl);
ProTKPrintf("Well done!");
return 0;
}
The function "ProEngineerStart" works well, I can open creo without problem. However when I try to display a model, a window pops up that says:
According to this link Re: Creo 2.0 Parametric Fatal Error encountered, I have insert a config.pro file in the directory containing traceback.log, i.e. C:\Users\fsd_proe\Desktop\Toolkit\17Console1\17Console1. But it doesn't work. In the directory C:\Users\Public\Documents, it doesn't work either. My computer is belonging to my university and Creo is installed under username as shown above and I work also in under this username.
My OS is win7 64bit and my image card is
Any help would be much appreciated! Thanks a lot!
Christian
Solved! Go to Solution.
The error is with your toolkit code.
Try this:
int main() {
char *a_char_ptr;
a_char_ptr= "C:\\Program Files\\PTC\\Creo 3.0\\M010\\Parametric\\bin\\parametric.bat";
ProError i= ProEngineerStart(a_char_ptr,"");
ProError status;
ProPath Mdlpath;
ProType MdlType;
ProMdl Mdl; // not a pointer
ProMdlName MdlName;
int w_id; // not a pointer
ProStringToWstring(Mdlpath,"C:\\Users\\fsd_proe\\Documents\\bauteil1.prt");
status =ProMdlFiletypeLoad(Mdlpath,PRO_MDLFILE_UNUSED,PRO_B_FALSE, &Mdl); // fills the address of the ProMdl
status=ProMdlTypeGet(Mdl, (ProMdlType*)&MdlType);
status=ProMdlMdlnameGet(Mdl, MdlName);
status= ProObjectwindowMdlnameCreate(MdlName, MdlType, &w_id); // fill the address
status=ProMdlDisplay(Mdl);
ProTKPrintf("Well done!");
return 0;
}
As a side note, if it generates a traceback.log file, and your code has a .PDB file, it should show you the line at which your code causes the failure.
It is good practice to always check the return value of the functions before continuing with the application (at least until you can be sure everything works under any condition)
e.g. what happens, if ProMdlFiletypeLoad() doesn't return a handle to the model for whatever reason?
Regards,
Gunter
The error is with your toolkit code.
Try this:
int main() {
char *a_char_ptr;
a_char_ptr= "C:\\Program Files\\PTC\\Creo 3.0\\M010\\Parametric\\bin\\parametric.bat";
ProError i= ProEngineerStart(a_char_ptr,"");
ProError status;
ProPath Mdlpath;
ProType MdlType;
ProMdl Mdl; // not a pointer
ProMdlName MdlName;
int w_id; // not a pointer
ProStringToWstring(Mdlpath,"C:\\Users\\fsd_proe\\Documents\\bauteil1.prt");
status =ProMdlFiletypeLoad(Mdlpath,PRO_MDLFILE_UNUSED,PRO_B_FALSE, &Mdl); // fills the address of the ProMdl
status=ProMdlTypeGet(Mdl, (ProMdlType*)&MdlType);
status=ProMdlMdlnameGet(Mdl, MdlName);
status= ProObjectwindowMdlnameCreate(MdlName, MdlType, &w_id); // fill the address
status=ProMdlDisplay(Mdl);
ProTKPrintf("Well done!");
return 0;
}
As a side note, if it generates a traceback.log file, and your code has a .PDB file, it should show you the line at which your code causes the failure.
James is right about the wrong levels of indirection!
I am marking his answer as Correct on behalf of Christian (it's a while back he filed the question, so probably found the error anyway)