Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello,
I am trying to write a C++ code into Creotoolkit to import relations from .txt format file and then regenerate the model. Can anybody guide me how can this be achieved?
TIA
Solved! Go to Solution.
Depending on what you need you might be able to use ProInputFileRead with the PRO_RELATION_FILE option. The relations.txt file would be in the working directory, but you can give a full path or most of the toolkit API's support using $ENVIRONMENT_VARIABLE.
//Use append_relations = 1 to append the relations and != 1 (ex: append_relations = 0) to replace the existing relations.
int append_relations = 1;
status = ProInputFileRead(mdl, L"relations.txt", PRO_RELATION_FILE, NULL, NULL, &append_relations, NULL);
status = ProSolidRegenerate((ProSolid)mdl, PRO_REGEN_NO_FLAGS);
If that doesn't meet your needs (example: needing to edit the post regeneration relations), you can read the text file line by line using something like wifstream to read each line from the text file and put it into an array of text lines. Then you can use ProArrayObjectAdd and ProRelsetRelationsSet like the example code from @msteffke.
Below is a chunk of code Ive done a few years ago. I was adding a line to the end of the relations of parts. Looking at the code here its not too difficult. Creo treats relations as an array of text lines. Its been a while since Ive worked with relations, but this worked for me in Creo 7.
Depending on what you need you might be able to use ProInputFileRead with the PRO_RELATION_FILE option. The relations.txt file would be in the working directory, but you can give a full path or most of the toolkit API's support using $ENVIRONMENT_VARIABLE.
//Use append_relations = 1 to append the relations and != 1 (ex: append_relations = 0) to replace the existing relations.
int append_relations = 1;
status = ProInputFileRead(mdl, L"relations.txt", PRO_RELATION_FILE, NULL, NULL, &append_relations, NULL);
status = ProSolidRegenerate((ProSolid)mdl, PRO_REGEN_NO_FLAGS);
If that doesn't meet your needs (example: needing to edit the post regeneration relations), you can read the text file line by line using something like wifstream to read each line from the text file and put it into an array of text lines. Then you can use ProArrayObjectAdd and ProRelsetRelationsSet like the example code from @msteffke.
Hi @ss_10739479,
I wanted to see if you got the help you needed.
If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation.
Thanks,