Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hello I was wondering if I may be doing something incorrectly or if anyone else has ran into similar issues.
I am attempting to modify existing SimpReps in a Creo assembly. When I go through the process there is no change to the SimpRep in the Creo assembly. Any insight or help would be appreciatted, below is the code segment where activeModel is a pfcModel_ptr retrieved from the session.
The model has SimpRep "INTERIOR" and it has a component with feature id = 450
pfcAssembly_ptr assem = pfcAssembly::cast(activeModel);
xintsequence_ptr ids = xintsequence::create();
ids->append(450);
pfcSimpRepItemPath_ptr sr_item_path = pfcSimpRepItemPath::cast(pfcSimpRepCompItemPath::Create(ids));
pfcSimpRepItem_ptr sr_item = pfcSimpRepItem::Create(sr_item_path);
pfcSimpRepAction_ptr action = pfcSimpRepAction::cast(pfcSimpRepInclude::Create());
sr_item->SetAction(action);
pfcSimpRepItems_ptr items = pfcSimpRepItems::create();
items->append(sr_item);
pfcSimpRep_ptr sr = assem->GetSimpRep("INTERIOR");
pfcSimpRepInstructions_ptr ins = sr->GetInstructions();
ins->SetDefaultAction(pfcSIMPREP_EXCLUDE);
ins->SetItems(items);
sr->SetInstructions(ins);
assem->ActivateSimpRep(sr);
Solved! Go to Solution.
I was able to get this working using the protoolkit functions, thanks @HannesBuxbaum for the suggestion.
This is the extracted code that works to use the protoolkit functions only where needed.
ProSimprepdata* simp_rep_data;
wchar_t sr_name[PRO_NAME_SIZE];
ProStringToWstring(sr_name, (char*)"INTERIOR");
ProSimprepdataAlloc(sr_name, PRO_B_FALSE, PRO_SIMPREP_EXCLUDE, &simp_rep_data);
xintsequence_ptr ids = xintsequence::create();
ids->append(450);
pfcModelItem_ptr md_item = pfcModelItem::cast(assem->GetFeatureById(450));
pfcComponentPath_ptr comp_path = pfcCreateComponentPath(assem, ids);
ProAsmcomppath* pro_comp_path = (ProAsmcomppath*)wfcGetHandleFromObject(pfcObject::cast(comp_path));
ProModelitem* pro_md_item = (ProModelitem*)wfcGetHandleFromObject(pfcObject::cast(md_item));
ProSimprepAction sr_action;
ProSimprepActionInit(PRO_SIMPREP_REVERSE, NULL, &sr_action);
ProSimprepitem sr_item;
ProSimprepdataitemInit(pro_comp_path->comp_id_table,
pro_comp_path->table_num, pro_md_item->id, &sr_action, &sr_item);
ProSimprepdataitemAdd(simp_rep_data, &sr_item);
ProSimprep simp_rep;
ProSimprepCreate((ProSolid)wfcGetHandleFromObject(pfcObject::cast(assem)), simp_rep_data, &simp_rep);*/
Hi @jack15,
Thank you for your question.
Your post appears well documented but has not yet received any response.
Feel free to add any additional information you think might be relevant:
And I am replying to raise awareness. Hopefully, another community member will be able to help.
Regards,
Vivek N
Community Moderation Team.
Hi @vnamboodheri
Here is that additional information:
1. PTC Creo Paraemtric 10.0.5.0 with included C++ toolkit
2. Open model > Run code snippet
3. I have only used the C++ provided toolkit
- For creating the SimpRepItems I have used `pfcSimpRepCompItemPath::Create`
- Modifying the SimpRep with 'SetItems(pfcSimpRepItems_ptr)
- Delete existing SimpRep and recreate with `pfcCreateNewSimpRepInstructions_ptr`
- tested with setting SimpRep items as USER_DEFINED as well as INCLUDE
- `pfcSimpRepExclude` is the default action
4. Example of INTERIOR SimpRep definition before running application:
After running application with `SetItems(items)`: where items only includes 10001259103<10001259098>.PRT
Hopefully this additional information may be useful
I don't have a solution, but "any insight" to offer: In 2018 I used the TOOLKIT (C) SimpRep API (with Creo 2 and 4) and found an error with ProSimprepdataitemsVisit(): it falsely returned old/invisible SimpRep items (not existing in the GUI), resulting in a wrong actual model structure being extracted. Not all models were affected by this error, but I had 10 affected ones.
I have no access to the PTC call that I opened therefore (but the call ID and my documentation) - not sure about the outcome.
That said, my suggestion in your case to use the C API (instead of C++) sounds not that promising, but I would try it.
Hello @jack15,
It looks like you have a response from a community member. If it helps to answer your question, please mark the reply as the Accepted Solution.
Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.
Thanks,
Vivek N.
Community Moderation Team.
I was able to get this working using the protoolkit functions, thanks @HannesBuxbaum for the suggestion.
This is the extracted code that works to use the protoolkit functions only where needed.
ProSimprepdata* simp_rep_data;
wchar_t sr_name[PRO_NAME_SIZE];
ProStringToWstring(sr_name, (char*)"INTERIOR");
ProSimprepdataAlloc(sr_name, PRO_B_FALSE, PRO_SIMPREP_EXCLUDE, &simp_rep_data);
xintsequence_ptr ids = xintsequence::create();
ids->append(450);
pfcModelItem_ptr md_item = pfcModelItem::cast(assem->GetFeatureById(450));
pfcComponentPath_ptr comp_path = pfcCreateComponentPath(assem, ids);
ProAsmcomppath* pro_comp_path = (ProAsmcomppath*)wfcGetHandleFromObject(pfcObject::cast(comp_path));
ProModelitem* pro_md_item = (ProModelitem*)wfcGetHandleFromObject(pfcObject::cast(md_item));
ProSimprepAction sr_action;
ProSimprepActionInit(PRO_SIMPREP_REVERSE, NULL, &sr_action);
ProSimprepitem sr_item;
ProSimprepdataitemInit(pro_comp_path->comp_id_table,
pro_comp_path->table_num, pro_md_item->id, &sr_action, &sr_item);
ProSimprepdataitemAdd(simp_rep_data, &sr_item);
ProSimprep simp_rep;
ProSimprepCreate((ProSolid)wfcGetHandleFromObject(pfcObject::cast(assem)), simp_rep_data, &simp_rep);*/