Smart Circular Loop Face Select

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!
duckmug
Posts: 126
Joined: Mon Jun 07, 2021 12:26 am

Smart Circular Loop Face Select

Post by duckmug »

I attempted searching for similar threads and came across something that mentioned holding down shift and selecting faces.

It doesn't seem to work. I want to basically be able to somehow easily select all those faces/triangles that are part of that same array.

The goal is to be able to easily add them to the defeaturing workbench list for further processing.

What would be the right way to do that?
Attachments
Screenshot from 2021-06-14 00-42-54.png
Screenshot from 2021-06-14 00-42-54.png (20.05 KiB) Viewed 1080 times
Last edited by duckmug on Mon Jun 14, 2021 12:40 am, edited 1 time in total.
drmacro
Veteran
Posts: 8806
Joined: Sun Mar 02, 2014 4:35 pm

Re: Smart Face Select

Post by drmacro »

Like in Blender...an actual native mesh modeler? :mrgreen:

Have you tried the Mesh or Defeaturing workbenches?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
duckmug
Posts: 126
Joined: Mon Jun 07, 2021 12:26 am

Re: Smart Face Select

Post by duckmug »

Yes, in the defeaturing workbench, there is a list that I can press the add button and have the selected faces be added there.

My issue is how to quickly select all those triangle faces that are part of that same circular array so that I can get them in there.

If GUI can't help with this, a scripting workaround would also work.
duckmug
Posts: 126
Joined: Mon Jun 07, 2021 12:26 am

Re: Smart Face Select

Post by duckmug »

Ok, I think I traced something that works very close, which is box selection, still not totally precise.

Would love to hear in case there's anything better that is particularly suited to circular loops of faces.
chrisb
Veteran
Posts: 53786
Joined: Tue Mar 17, 2015 9:14 am

Re: Smart Circular Loop Face Select

Post by chrisb »

I wanted to check, but FreeCAD crashes on two of the meshers, and the default looked quite different, so my question is, if defeaturing works after all. Does it create a conical shape, even if everything around is flat?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
duckmug
Posts: 126
Joined: Mon Jun 07, 2021 12:26 am

Re: Smart Circular Loop Face Select

Post by duckmug »

Yes defeaturing works fine here.
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Smart Circular Loop Face Select

Post by heda »

fc is probably the best cad system around to script in,
and a bit of python should really be possible for most people,
combine that with an ounce of determination to get things done...

an example of a slow and naive algo...

Code: Select all

# select a face on a refined solid, originating from a mesh
# run macro, adds all adjecent faces to selection

from itertools import chain, combinations

s, = Gui.Selection.getSelectionEx()

obj = s.Object
selface, = s.SubObjects
selfacename, = s.SubElementNames
selfaceid = int(selfacename.replace('Face', ''))
print('Selected face: {} in {}'.format(s.ObjectName, selfacename))

Gui.Selection.clearSelection()

def xyz(vert):
    return vert.X, vert.Y, vert.Z

def face_verts(face):
    return (xyz(v) for v in face.Vertexes)

def common_vert(fa, fsv):
    pairs = combinations(chain(face_verts(fa), fsv), 2)
    return sum(i == j for i, j in pairs)

faces = obj.Shape.Faces
selfaceverts = tuple(face_verts(selface))
hits = list()

for i, face in enumerate(faces, start=1):
    if i == selfaceid: continue
    found = common_vert(face, selfaceverts)
    if found:
        hits.append('Face{}'.format(i))

Gui.Selection.addSelection(obj, hits)
print('ready')
duckmug
Posts: 126
Joined: Mon Jun 07, 2021 12:26 am

Re: Smart Circular Loop Face Select

Post by duckmug »

Thank you so much, that is pretty handy!

Update: I tested it and it doesn't seem to select them in my case.
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Smart Circular Loop Face Select

Post by heda »

well, the code does what it does, not necessarily what you are after
it is just one example intended to illustrate that it is not that hard to script in fc,
it simply is one way to select adjacent faces.
could be coded differently, like using vector distances and still do the same.

feel free to tweak it to your own needs.
duckmug
Posts: 126
Joined: Mon Jun 07, 2021 12:26 am

Re: Smart Circular Loop Face Select

Post by duckmug »

Yes I understand and appreciate your effort regardless, will try to play with it.
Post Reply