Skip to main content
12-Amethyst
September 21, 2023
Solved

C++ toolkit how to recognize predefined flexibility

  • September 21, 2023
  • 2 replies
  • 2026 views

I am working on creating an application to insert parts into an assembly. I want to be able to recognize that a model being has predefined flexibility. When operating Creo manually if you insert a model with predefined flexibility Creo will tell you that and ask if you want to use it. However there does not seem to be an equivalent function in the C++ toolkit.

What I have been trying to use is the method wfcWModel::isVariantFeatModel(), however this always returns false. I have tried using pfcSession::RetrieveModel() and pfcSession::GetModelFromFilename() to retrieve the model before checking it, but both yield the same result.

I am hoping that someone may have some insight to make this work.

I will also note that the method wfcWComponentFeat::IsFlexible() exists but this will only recognize components that already have flexibility 'turned on'

 

 

 

Best answer by RPN

I did not tested my guess 😉


But after you have assembled the model with


extern ProError
ProAsmcompAssemble (

ProAssembly owner_assembly,

ProSolid component_model,
ProMatrix init_pos,
ProAsmcomp *feature );

You have it in your assembly, now use 

 

extern ProError ProAsmcompFlexibleWithPredefineditemsSet (ProAsmcomp *comp);
/*
Purpose: convert the specified component to flexible one using the predefined
flexibility varied items defined on its component model.

Input Arguments:
comp - The component to be converted to flexible one

Output Arguments:
None

Return Values:
PRO_TK_NO_ERROR - The function succeeded
PRO_TK_BAD_INPUTS - The input argument is invalid.

 

Based on the status you may know if you have assembled a flexible component. You can still convert the model to be not flexible.

I think you have first to assemble, and before you apply constraints, check for a flexible component. There are other functions for flexible components, but I think you need to deal with the return status.

 

Nice riddle😉

 

2 replies

17-Peridot
September 25, 2023

I don't know how to check not assembled model. But you can use a function at assembled component

wfcWComponentFeat::CreatePredefinedFlexibilityComponent

If the model has predefined flexibility, then this function return no error.

jack1512-AmethystAuthor
12-Amethyst
September 25, 2023

Hey this one doesn't work without already knowing the AsmItems. This function will also return no error even if the component does not have predefined flexibility as long as the items passed in with AsmItems are valid parameters/dimensions.

My goal is to be able to recognize a flexible component and get the varied items before it is fully inserted, like how it works when a flexible part is added to an assembly in Creo manually.

RPN
RPN18-OpalAnswer
18-Opal
September 25, 2023

I did not tested my guess 😉


But after you have assembled the model with


extern ProError
ProAsmcompAssemble (

ProAssembly owner_assembly,

ProSolid component_model,
ProMatrix init_pos,
ProAsmcomp *feature );

You have it in your assembly, now use 

 

extern ProError ProAsmcompFlexibleWithPredefineditemsSet (ProAsmcomp *comp);
/*
Purpose: convert the specified component to flexible one using the predefined
flexibility varied items defined on its component model.

Input Arguments:
comp - The component to be converted to flexible one

Output Arguments:
None

Return Values:
PRO_TK_NO_ERROR - The function succeeded
PRO_TK_BAD_INPUTS - The input argument is invalid.

 

Based on the status you may know if you have assembled a flexible component. You can still convert the model to be not flexible.

I think you have first to assemble, and before you apply constraints, check for a flexible component. There are other functions for flexible components, but I think you need to deal with the return status.

 

Nice riddle😉

 

jack1512-AmethystAuthor
12-Amethyst
September 26, 2023

Thank you RPN! 

This method was exactly what I needed 🙂 

extern ProError ProAsmcompFlexibleWithPredefineditemsSet (ProAsmcomp *comp);