Personal tools
You are here: Home Forum Use Script python - Filter - How to remove a parent group without removing the children group

Script python - Filter - How to remove a parent group without removing the children group

Up to Use

Script python - Filter - How to remove a parent group without removing the children group

Posted by Yohann Eude at December 17. 2018

Hello,

 

In my python script (MESH Part), I try to remove the group "Group_Parent" that I used to create the "Group_Children" with a filter, but the  "Group_Children" is lost with the "Group_Parent". How can I keep the "Group_Children" after removing the "Group_Parent"?

I use Salome 8.5.

Thank you for your help,

Yohann

Re: Script python - Filter - How to remove a parent group without removing the children group

Posted by Saint Michael at December 18. 2018

Hi Yohann

You forgot to attach your script.

St.Michael

Re: Script python - Filter - How to remove a parent group without removing the children group

Posted by Yohann Eude at December 18. 2018

I can't share the entire script, here the concerning part:

When I remove inlet_outlet_9, I lost the groups inlet_1 inlet_2 inlet_3 and outlet_1 outlet_2 outlet_3.

 

aCriteria = []
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_BelongToMeshGroup,SMESH.FT_Undefined,inlet_outlet_9,SMESH.FT_Undefined,SMESH.FT_LogicalAND)
aCriteria.append(aCriterion)
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_LyingOnGeom,SMESH.FT_Undefined,Cut_8)
aCriteria.append(aCriterion)
aFilter_1 = smesh.GetFilterFromCriteria(aCriteria)
aFilter_1.SetMesh(Compound_Mesh_4.GetMesh())
outlet_3 = Compound_Mesh_4.GroupOnFilter( SMESH.FACE, 'outlet_3', aFilter_1 )
aCriteria = []
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_BelongToMeshGroup,SMESH.FT_Undefined,inlet_outlet_9,SMESH.FT_Undefined,SMESH.FT_LogicalAND)
aCriteria.append(aCriterion)
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_LyingOnGeom,SMESH.FT_Undefined,Cut_7)
aCriteria.append(aCriterion)
aFilter_2 = smesh.GetFilterFromCriteria(aCriteria)
aFilter_2.SetMesh(Compound_Mesh_4.GetMesh())
outlet_2 = Compound_Mesh_4.GroupOnFilter( SMESH.FACE, 'outlet_2', aFilter_2 )
aCriteria = []
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_BelongToMeshGroup,SMESH.FT_Undefined,inlet_outlet_9,SMESH.FT_Undefined,SMESH.FT_LogicalAND)
aCriteria.append(aCriterion)
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_LyingOnGeom,SMESH.FT_Undefined,Cut_9)
aCriteria.append(aCriterion)
aFilter_3 = smesh.GetFilterFromCriteria(aCriteria)
aFilter_3.SetMesh(Compound_Mesh_4.GetMesh())
outlet_1 = Compound_Mesh_4.GroupOnFilter( SMESH.FACE, 'outlet_1', aFilter_3 )
aCriteria = []
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_BelongToMeshGroup,SMESH.FT_Undefined,inlet_outlet_9,SMESH.FT_Undefined,SMESH.FT_LogicalAND)
aCriteria.append(aCriterion)
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_LyingOnGeom,SMESH.FT_Undefined,Common_2)
aCriteria.append(aCriterion)
aFilter_4 = smesh.GetFilterFromCriteria(aCriteria)
aFilter_4.SetMesh(Compound_Mesh_4.GetMesh())
inlet_2 = Compound_Mesh_4.GroupOnFilter( SMESH.FACE, 'inlet_2', aFilter_4 )
aCriteria = []
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_BelongToMeshGroup,SMESH.FT_Undefined,inlet_outlet_9,SMESH.FT_Undefined,SMESH.FT_LogicalAND)
aCriteria.append(aCriterion)
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_LyingOnGeom,SMESH.FT_Undefined,Common_3)
aCriteria.append(aCriterion)
aFilter_5 = smesh.GetFilterFromCriteria(aCriteria)
aFilter_5.SetMesh(Compound_Mesh_4.GetMesh())
inlet_3 = Compound_Mesh_4.GroupOnFilter( SMESH.FACE, 'inlet_3', aFilter_5 )
aCriteria = []
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_BelongToMeshGroup,SMESH.FT_Undefined,inlet_outlet_9,SMESH.FT_Undefined,SMESH.FT_LogicalAND)
aCriteria.append(aCriterion)
aCriterion = smesh.GetCriterion(SMESH.FACE,SMESH.FT_LyingOnGeom,SMESH.FT_Undefined,Common_4)
aCriteria.append(aCriterion)
aFilter_6 = smesh.GetFilterFromCriteria(aCriteria)
aFilter_6.SetMesh(Compound_Mesh_4.GetMesh())
inlet_1 = Compound_Mesh_4.GroupOnFilter( SMESH.FACE, 'inlet_1', aFilter_6 )

Compound_Mesh_4.RemoveGroup( inlet_outlet_9 )

Re: Script python - Filter - How to remove a parent group without removing the children group

Posted by Saint Michael at December 18. 2018

You can create a standalone group instead of a group on filter, but using elements satisfying a filter.

E.g. replace

inlet_1 = Compound_Mesh_4.GroupOnFilter( SMESH.FACE, 'inlet_1', aFilter_6 )

by

inlet_1 = Compound_Mesh_4.MakeGroupByIds(  'inlet_1', SMESH.FACE, aFilter_6 )

St.Michael

Re: Script python - Filter - How to remove a parent group without removing the children group

Posted by Yohann Eude at December 18. 2018

Thank you, it works!

Powered by Ploneboard
Document Actions