Personal tools
You are here: Home Forum Use creating groups SHAPER

creating groups SHAPER

Up to Use

creating groups SHAPER

Posted by Franco Otaola at December 07. 2020

hello,

I am trying to create groups in shaper,

want to create 3 groups from a quarter of cylinder:
1: horizontal face at z=10
2: horizontal face at z=0
3: all surfaces minus 1 and 2

I have successfully done this in the GUI by, 
1. creating a plane at z=10
2. creating a group and using two filters, a. belongs to (and select the body) b. on plane and select the plane
I re do this to create the second group,
then create a group with all faces and remove the other two groups from it.

what I was looking to is to dump this study and use it to create groups with more complex geometry in the same idea (two groups for two horizontal planes and the third for everything else)
my problem is that when I dump the file I loose information, about the filtering, for example for the first group I am getting:

### Create Group

Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_2"), model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = [model.selection()]), model.addFilter(name = "OnPlane", args = [model.selection()])])])
Group_1.setName("inlet") #
Group_1.result().setName("inlet")

as can be observed actually the dumb study uses already the "result" from the filtering ( model.selection("FACE", "Cylinder_1_1/Face_2")) but it is not using the filters (as the args are empty). how could I re do this to be used with other geometries?(as the face could change when the geometry changes)

I was trying something like this (without luck):
Group_1 = model.addGroup(Part_1_doc, "Faces", [ model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = [model.selection(Cylinder_1.result())]), model.addFilter(name = "OnPlane", args = [model.selection(plane_1.result())])])])

 

best regards,

Re: creating groups SHAPER

Posted by Franco Otaola at December 07. 2020

what I progress,

if I in the script I use:

filt_2= model.addFilter(name = "OnPlane", args = [ Plane_4.result()]);
filt_1= model.addFilter(name = "BelongsTo", args = [Cylinder_1.result()]);
faces= model.filters(Part_1_doc, [filt_1, filt_2])
Group_1 = model.addGroup(Part_1_doc, "Faces",  [faces])
Group_1.setName("inlet") 
Group_1.result().setName("inlet")

when I enter to the result in the GUI I have the inlet group with a red/black cross if I edit it, I can see that there is nothing selected, but if I enter the selection by filters the filters are there but it looks like they are not executed as when I click in "select" it selects the correct faces and I only need to apply it, then i go back to the create group feature with the correct face selected.

Re: creating groups SHAPER

Posted by Gérald NICOLAS at December 11. 2020

Correct. The filters are only tools to build groups but only the results is saved. So you cannot replay them.

Re: creating groups SHAPER

Posted by Franco Otaola at December 14. 2020

helo Gérald, my issue is still there, I can not use the filters to create groups in SHAPER TUI, as I mentioned in my second post, my script creates the group with the desired filters but it does not apply it, so I need to re enter to the GUI and click "select" in the filter creations that obviously all scripting possibilities are broken after this. my problem is, I dont know (and I did not find it in the documentation either)

how to create the filters and apply them to get the selected objects.


best regards,

F.

Previously Gérald NICOLAS wrote:

Correct. The filters are only tools to build groups but only the results is saved. So you cannot replay them.

 

Re: creating groups SHAPER

Posted by Franco Otaola at February 09. 2021

Dear Gerald,

I still could not find a way to get the faces that will be selected by the filter from the TUI.
as I mentioned before, when I excecute the TUI script, the group feature is shown with a red cross as nothing is selected in the feature and when I enter to selection by filters, the filters I created previously by the TUI, for example the filter "On plane" and the correct plane is already selected, but not the faces that are in that plane are selected (this action is done by the bottom "select" in the GUI inside the filter menu) so the TUI script until the model.filters (from my previous message) is working but between the variable "faces" and the creation of "Group_1" there still something missing (the action that i mentioned previously that in the GUI is clicking in the botton "select" and apply it)

do you have any idea how can i achive this to make work the TUI script directly?

please see attached script, where an example is done for this situation, when you load the script go to sharper module -> edit "inlet" feature -> selection by filters (and there you will find the two correctly created filters from the script that are not being "executed") -> click select -> apply -> apply and the group is correctly created.

best regards,

Attachments

Re: creating groups SHAPER

Posted by Franco Otaola at April 19. 2021

Hello,

for any who reads this post in search of a solution, For the moment, the creation of groups is not fully implemented in the shaper module (at this moment). In any case, the correct script is in this comment, for the moment faces.feature().results() will give an empty list (because it is not fully implemented).

best regards,

franco

 

 

Previously Franco Otaola wrote:

Dear Gerald,

I still could not find a way to get the faces that will be selected by the filter from the TUI.
as I mentioned before, when I excecute the TUI script, the group feature is shown with a red cross as nothing is selected in the feature and when I enter to selection by filters, the filters I created previously by the TUI, for example the filter "On plane" and the correct plane is already selected, but not the faces that are in that plane are selected (this action is done by the bottom "select" in the GUI inside the filter menu) so the TUI script until the model.filters (from my previous message) is working but between the variable "faces" and the creation of "Group_1" there still something missing (the action that i mentioned previously that in the GUI is clicking in the botton "select" and apply it)

do you have any idea how can i achive this to make work the TUI script directly?

please see attached script, where an example is done for this situation, when you load the script go to sharper module -> edit "inlet" feature -> selection by filters (and there you will find the two correctly created filters from the script that are not being "executed") -> click select -> apply -> apply and the group is correctly created.

best regards,

 

Attachments

Re: creating groups SHAPER

Posted by mihe at August 20. 2021

I have a related question about creating groups from the python console.

In the gui with the shaper group command I can see that the name of a face is: Partition_1_1_1/Modified_Face&M115x3-MALE_1/Shape_7&M115x3-FEMALE_1/Shape_398

I then try to create a group XXX with this face with the following code:

from ModelAPI import *

model.begin()

partSet = model.moduleDocument()

aPart = objectToFeature(partSet.object("Features", 0))

aPartResult = modelAPI_ResultPart(aPart.results()[0])

Part_1_doc = aPartResult.partDoc()

Group_8 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Partition_1_1_1/Modified_Face&M115x3-MALE_1/Shape_3&M115x3-FEMALE_1/Shape_398")])

Group_8.setName("XXX")

Group_8.result().setName("XXX")

I get no error messages but the created group is empty. Why?

BR/Micke

Re: creating groups SHAPER

Posted by mihe at August 21. 2021

I guess this is closer to the solution but it still does not work:

nedan funkar... inte...

 

from ModelAPI import *

model.begin()

 

partSet = model.moduleDocument()

aPart = objectToFeature(partSet.object("Features", 0))

aPartResult = modelAPI_ResultPart(aPart.results()[0])

Part_1_doc = aPartResult.partDoc()

 

Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "[Partition_1_1_1/Modified_Face&M115x3-MALE_1/Shape_7&M115x3-FEMALE_1/Shape_398]"), ])

Group_1.result().setName("XXX")

model.do()

model.end()

 

I get error message "Modification of data structure outside of the transaction".

BR/Micke

Re: creating groups SHAPER

Posted by mihe at August 22. 2021

If I create a primitive box the code below can successfully create a group with a face on the box:

 

from ModelAPI import *

from salome.shaper import model

model.begin()

partSet = model.moduleDocument()

aPart = objectToFeature(partSet.object("Features", 0))

aPartResult = modelAPI_ResultPart(aPart.results()[0])

Part_1_doc = aPartResult.partDoc()

Group_5 = model.addGroup(Part_1_doc, [model.selection("FACE", "[Box_1_1/Top]"), ])

Group_5.result().setName("F5")

model.do()

model.end()

 

However if I save the model and then reopen it the same code just creates a empty group. 

If, in the saved model, I create a new box Box_2_1. The code successfully creates a group (with model.addGroup(Part_1_doc, [model.selection("FACE", "[Translation_1_1/MF:Translated&Box_2_1/Top]"), ]) ).

 

- How can I make the code work on saved geometry?

BR/Micke

Re: creating groups SHAPER

Posted by mihe at August 22. 2021

After some more testing the situation is that the code given above works but only on faces created after the model was opened. So if I save, close and re-open a model again the code only creates a empty group for existing faces. If a new face, e.g. a chamfer, is created then the code forks for that face.

-Is this the expected behavior?

-Is it possible to modify the code so that it works for any face?

Any inputs are welcome.

I am running Salome 9.6/Micke 

 

Re: creating groups SHAPER

Posted by Christophe Bourcier at August 23. 2021

Hi Micke,

I have reproduced the issue you're describing. We'll try to see why it happens.

In the meantime, you can use the alternative way to create groups by selecting sub-shapes with a point coordinates, for instance:

Group_5 = model.addGroup(Part_1_doc, [model.selection("FACE", (0, 5, 5))])

To generate the dump with this alternative selection mechanism, you can call the feature dump (from the Part menu) , it will generate a file with _geo.py suffix.

Best regards,

Christophe

Re: creating groups SHAPER

Posted by mihe at August 27. 2021
Thank you for looking into this. I will try the alternative method also.BR/Micke
 
Powered by Ploneboard
Document Actions