Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hello
I am trying tonimport relation into Creo using toolkit C++ from a txt file stored in my PC.
I am using function ProInputFileRead().
Syntax :
ProMdl model;
ProPath filename;
ProAppData arg1 = NULL;
ProAppData arg1 = NULL;
int arg3_value = 0;
ProAppData arg3 = &arg3_value;
ProAppData arg4= NULL;
ProStringToWstring (filename, "C:\\filepath");
ProInputFileRead (model,filename, PRO_RELATION_FILE, arg1, arg2, arg3, arg4);
ProSolidRegenerate((ProSolid)model, PRO_REGEN_NO_FLAGS);
Can anyone suggest is something wrong with this? As I am unable to achieve importing. Txt and assigning relations to model.
Solved! Go to Solution.
Your code example has very small chances to be executed correctly. Here is why:
- Calling ProEngineerStart in user_initialize function make no sense. You already have a active Creo session and you toolkit application will automatically "attach" to that session. This is the purpose of user_initialize function.
- "ProMdlCurrentGate" There is no such function in the toolkit API's
- ProEngineerEnd(); This will end your Creo session and all the changes will be lost. Even if everything works correctly you will not be able to see the results.
Try the following:
Remove the ProEngineerEnd call, fix the code so it can compile and execute, add some messages in you code to show you which function failed and what was the status that was returned.
After you are able to run your code, post the results here.
Right now there are not enough information for someone to be able to help.
What return codes do ProInputFileRead and ProSolidRegenerate give?
filename should have the input filename and extension also included, whereas here it looks like you have set it to just "C:\\filepath" rather than "C:\\filepath\\relation.txt" for example
I have used a ProError status variable and used it like
status = ProInputFileRead(.....);
If (status!= PRO_TK_NO_ERROR){
return status;
}
Secondly I have written this code directly into main function having return type ProError.
Yes I have mentioned the file location till .txt
Are you able to provide sample files and the code you have used?
The abridged code looks to be okay here, so there isn't any obvious indication of what the issue is.
The code is
Should you call ProMdlSave before ProEngineerEnd to save the updates made?
I am able to load model and display it also in Creo. The next step I want to achieve is to import relations from txt file I used ProInputFileRead but I am not able to update relations using text file. I checked path and everything is correct.
What can be the cause for not importing txt file and updating relations?
Your code example has very small chances to be executed correctly. Here is why:
- Calling ProEngineerStart in user_initialize function make no sense. You already have a active Creo session and you toolkit application will automatically "attach" to that session. This is the purpose of user_initialize function.
- "ProMdlCurrentGate" There is no such function in the toolkit API's
- ProEngineerEnd(); This will end your Creo session and all the changes will be lost. Even if everything works correctly you will not be able to see the results.
Try the following:
Remove the ProEngineerEnd call, fix the code so it can compile and execute, add some messages in you code to show you which function failed and what was the status that was returned.
After you are able to run your code, post the results here.
Right now there are not enough information for someone to be able to help.