Skip to main content
14-Alexandrite
Aug 1, 2024 12:00 PM UTC
Solved

Importing relations into creo using toolkit

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.

14-Alexandrite
Aug 6, 2024 1:46 PM UTC

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.

7 replies

12-Amethyst
Aug 1, 2024 12:47 PM UTC

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

Translate
14-Alexandrite
Aug 1, 2024 1:32 PM UTC

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

 

 

 

Translate
12-Amethyst
Aug 1, 2024 1:44 PM UTC

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.

Translate