cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Importing relations into creo using toolkit

Marcusanthony
14-Alexandrite

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.

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

7 REPLIES 7

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

Marcusanthony
14-Alexandrite
(To:Ben_C)

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.

Marcusanthony
14-Alexandrite
(To:Ben_C)

The code is 

 

 

#include <ProToolkit.h>
#include <ProUtil.h>
#include <ProMdl.h>
#include <ProSolid.h>
#include <ProFeature.h>
#include <ProFeatType.h>
#include <ProModelitem.h>
#include <ProUIDialog.h>
#include <ProMessage.h>
#include <ProRelSet.h>




extern "C" ProErorr user_initialize(int argc, char* argv[]){
    ProError status;
    ProMdl model;
    ProPath filename;
    ProAppData arg1;
    ProAppData arg2;
    int arg3_value = 0;
    ProAppData arg3= &arg3_value;
    ProAppData arg4;
 
   status = ProEngineerStart(NULL, NULL);
    if(status != PRO_TK_NO_ERROR){
        return status;
    }
   
    status = ProMdlCurrentGet(&model);
    if(status != PRO_TK_NO_ERROR){
        return status;
    }

    status = ProMdlCurrentGate(&model);
    if(status != PRO_TK_NO_ERROR){
        return status;
    }

    ProStringToWstring(filename, "C:\\Users\\Desktop\\test.txt");

    status=ProInputFileRead(model, filename, arg1, arg2, arg3, arg4);
    if(status != PRO_TK_NO_ERROR){
        return status;
    }

    status = ProSolidRegenerate((ProSolid)model, PRO_REGEN_NO_FLAGS);
    if(status != PRO_TK_NO_ERROR){
        return status;
    }

    ProEngineerEnd();
    return PRO_TK_NO_ERROR;
}

extern "C" void user_terminate(){
   
}

Should you call ProMdlSave before ProEngineerEnd to save the updates made?

Marcusanthony
14-Alexandrite
(To:Ben_C)

 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.

Announcements


Top Tags