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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Toolkit: ProMdlCombStateCreate() - How 2 add layer state

AndreasHellmann
3-Visitor

Toolkit: ProMdlCombStateCreate() - How 2 add layer state

Hi,

was anyone of you able to define a new Combined State in a Creo model and add a layer state item to the array of items???

All the other items (Xsec, SimpRep, View, ExplodeState, StyleState) I am able to set, but not the layer state.

In my applications the layer state is simply being ignored (no error when adding a model item).

What I tried so far...

Because there is no function "ProLayerstateInit()" I used for my first try (do the initialization with ProModelitemByNameInit()) :

ProModelitem *CombStateItemArr;

ProLayerstate hLayerStateItem;

status = ProModelitemByNameInit (MyAssembly, PRO_LAYER_STATE, wLayerStateName, &hLayerStateItem);

status = ProArrayObjectAdd ((ProArray*)&CombStateItemArr, -1, 1, &hLayerStateItem);

My second try (get all layer states in the assembly with ProLayerstatesGet():

status = ProLayerstatesGet (MyAssembly, &LayerStateArr);

Then I loop through all array elements in LayerStateArray and check the name against the layer state name I want to set....

ANY IDEAS?

Otherwise I have to open a case with PTC.

Andreas Hellmann


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
3 REPLIES 3

Hi Andreas -

Are you trying to create a new Combined State which includes your Layer State, or are you trying to add a Layer State to an existing Combined State?

Both should be possible, as far as I know.

was anyone of you able to define a new Combined State in a Creo model and add a layer state item to the array of items???

All the other items (Xsec, SimpRep, View, ExplodeState, StyleState) I am able to set, but not the layer state.

In my applications the layer state is simply being ignored (no error when adding a model item).

What I tried so far...

Because there is no function "ProLayerstateInit()" I used for my first try (do the initialization with ProModelitemByNameInit()) :

ProModelitem *CombStateItemArr;

ProLayerstate hLayerStateItem;

status = ProModelitemByNameInit (MyAssembly, PRO_LAYER_STATE, wLayerStateName, &hLayerStateItem);

status = ProArrayObjectAdd ((ProArray*)&CombStateItemArr, -1, 1, &hLayerStateItem);

My second try (get all layer states in the assembly with ProLayerstatesGet():

status = ProLayerstatesGet (MyAssembly, &LayerStateArr);

Then I loop through all array elements in LayerStateArray and check the name against the layer state name I want to set....

I have used your second approach successfully. Your first approach appears valid, too.

Once you have identified the Layer State you want, you should be able to include it in the model item array for either ProMdlCombStateCreate() or ProCombstateRedefine().  If those functions don't accept your layer state, I would open a support call with PTC.

|+|  M a r k  |+|

Hi Mark,

thanks for the answer. I was trying to add a layer state to modelitem array for a NEW combined state.

Could you please check your code - did you use some cast like (ProModelitem*) when referring to the layer state item?

I will try it again in the next days and -yes- I will open a call with PTC.

Andreas

Andreas -

In my code, I did not need to cast ProLayerstate to ProModelitem. I used a std::vector<ProModelitem> to collect the various features, layer states, etc, then converted the vector to a ProArray just before calling ProMdlCombStateCreate.

I'm sure that you already know that ProLayerstate has the same declaration as ProModelitem:

typedef struct pro_model_item

{

  ProType  type;

  int      id;

  ProMdl owner;

} ProModelitem, ProGeomitem, ProExtobj, ProFeature, ProProcstep,

  ProSimprep, ProExpldstate, ProLayer, ProDimension, ProDtlnote,

  ProDtlsyminst, ProGtol, ProCompdisp, ProDwgtable, ProNote,

  ProAnnotationElem, ProAnnotation, ProAnnotationPlane,

  ProSymbol, ProSurfFinish, ProMechItem, ProMaterialItem, ProCombstate,

  ProLayerstate;

The ProType value is what distinguishes a ProLayerstate from a ProGeomitem or other ProModelitem type.

If your compiler gives a warning about assigning a ProLayerstate to a ProModelitem field, then it should be fine for you to use a cast. I don't think it should otherwise be necessary.

|+|  M a r k  |+|

Top Tags