Select face by expression

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
FredOP
Posts: 51
Joined: Sat Sep 26, 2020 1:25 pm

Select face by expression

Postby FredOP » Thu Oct 29, 2020 10:38 am

Is there a notion in FreeCAD of using some code to selection faces and edges, rather than by name ?
Coming from SideFX Houdini, I'm used to just throw some code in a point wrangle when I need a feature that doesn't exist, and I'm looking for something that feels that way in FreeCAD.
chrisb
Posts: 29060
Joined: Tue Mar 17, 2015 9:14 am

Re: Select face by expression

Postby chrisb » Thu Oct 29, 2020 11:19 am

You can throw in some Python code in the Python console.
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
FredOP
Posts: 51
Joined: Sat Sep 26, 2020 1:25 pm

Re: Select face by expression

Postby FredOP » Thu Oct 29, 2020 1:09 pm

chrisb wrote:
Thu Oct 29, 2020 11:19 am
You can throw in some Python code in the Python console.
But this would be executed just once ?
openBrain
Posts: 4874
Joined: Fri Nov 09, 2018 5:38 pm

Re: Select face by expression

Postby openBrain » Thu Oct 29, 2020 1:11 pm

Can you try to better explain what exactly you're trying to achieve? Ideally give an example.
jmaustpc
Posts: 10382
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Select face by expression

Postby jmaustpc » Thu Oct 29, 2020 1:16 pm

FredOP wrote:
Thu Oct 29, 2020 1:09 pm
chrisb wrote:
Thu Oct 29, 2020 11:19 am
You can throw in some Python code in the Python console.
But this would be executed just once ?
You can save any Python code as a macro, see the FreeCAD macro tool

Like openbrain said,explain what you mean. Your post doesn't make sense at least not to me.
FredOP
Posts: 51
Joined: Sat Sep 26, 2020 1:25 pm

Re: Select face by expression

Postby FredOP » Thu Oct 29, 2020 1:22 pm

openBrain wrote:
Thu Oct 29, 2020 1:11 pm
Can you try to better explain what exactly you're trying to achieve? Ideally give an example.
Select the faces which normal is parallel to a given direction within a certain angular deviation.
Pad them.
openBrain
Posts: 4874
Joined: Fri Nov 09, 2018 5:38 pm

Re: Select face by expression

Postby openBrain » Thu Oct 29, 2020 1:32 pm

FredOP wrote:
Thu Oct 29, 2020 1:22 pm
Select the faces which normal is parallel to a given direction within a certain angular deviation.
Pad them.
You can write a macro that will take as input a selected edge, compute all face normals, check which one are in a defined deviation tolerance, and extrude them. Just a bit of Python, maths and FC API. ;)
FredOP
Posts: 51
Joined: Sat Sep 26, 2020 1:25 pm

Re: Select face by expression

Postby FredOP » Thu Oct 29, 2020 1:43 pm

openBrain wrote:
Thu Oct 29, 2020 1:32 pm
FredOP wrote:
Thu Oct 29, 2020 1:22 pm
Select the faces which normal is parallel to a given direction within a certain angular deviation.
Pad them.
You can write a macro that will take as input a selected edge, compute all face normals, check which one are in a defined deviation tolerance, and extrude them. Just a bit of Python, maths and FC API. ;)
Can a macro be executed at a certain point in the workflow, like any other feature ?
chrisb
Posts: 29060
Joined: Tue Mar 17, 2015 9:14 am

Re: Select face by expression

Postby chrisb » Thu Oct 29, 2020 1:44 pm

FredOP wrote:
Thu Oct 29, 2020 1:22 pm
Select the faces which normal is parallel to a given direction within a certain angular deviation.
Pad them.
Your explanation is still rather short. Do you want to perform the select via code? And how is the direction given? And how do you provide the angular deviation?
Please note that we have absolutely no idea what you are modeling, what you want to have in the end, and I dare to say, most people here don't know SideFX Houdini. At least the name sounds like a magician's trick.
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
openBrain
Posts: 4874
Joined: Fri Nov 09, 2018 5:38 pm

Re: Select face by expression

Postby openBrain » Thu Oct 29, 2020 1:48 pm

FredOP wrote:
Thu Oct 29, 2020 1:43 pm
Can a macro be executed at a certain point in the workflow, like any other feature ?
Sort of. You can create a so-called 'scripted object' that will appear in the tree as a feature and define a specific behavior.
In your case looks possible to have such an object with a property holding the edge defining the direction, and another one a list of child objects (and eventually another for deviation tolerance, another for extrude length,...) and implementing your wanted behavior.