PathSelection.surfaceselect() behaviour?

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

PathSelection.surfaceselect() behaviour?

Post by agren »

Hi all,

I'm looking at the selection gate code for the 3D operations and have come across something I don't understand.
To me it seems the following code have no effect.

Code: Select all

def surfaceselect():
    gate = False
    if MESHGate() or FACEGate():
        gate = True
    FreeCADGui.Selection.addSelectionGate(gate)
    if not PathPreferences.suppressSelectionModeWarning():
        FreeCAD.Console.PrintWarning("Surfacing Select Mode\n")
source

The first thing is that "MESHGate() or FACEGate()" is truthy, so "gate = True" will always be evaluated.
The second thing is that the documentation of "addSelectionGate" does not say that it can take a bool as argument.

Looking at the other *select functions I would expect the code to look something like this:

Code: Select all

def surfaceselect():
    FreeCADGui.Selection.addSelectionGate(MESHGate())
    FreeCADGui.Selection.addSelectionGate(FACEGate())
    if not PathPreferences.suppressSelectionModeWarning():
        FreeCAD.Console.PrintWarning("Surfacing Select Mode\n")

Thankful for any insight into how it works or should work.
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: PathSelection.surfaceselect() behaviour?

Post by sliptonic »

agren wrote: Fri Jul 15, 2022 8:11 pm I'm looking at the selection gate code for the 3D operations and have come across something I don't understand.
To me it seems the following code have no effect.
Yes, you're correct. Testing it from the python console shows nothing happening.
The first thing is that "MESHGate() or FACEGate()" is truthy, so "gate = True" will always be evaluated.
Yep, you're right.
The second thing is that the documentation of "addSelectionGate" does not say that it can take a bool as argument.

Looking at the other *select functions I would expect the code to look something like this:

Code: Select all

def surfaceselect():
    FreeCADGui.Selection.addSelectionGate(MESHGate())
    FreeCADGui.Selection.addSelectionGate(FACEGate())
    if not PathPreferences.suppressSelectionModeWarning():
        FreeCAD.Console.PrintWarning("Surfacing Select Mode\n")
This won't work. There's always just one selection gate active at a time. If you do it this way, MESHGate gets added and then immediately replaced with FACEGate.

We need a new selectiongate class whose allow() method returns true for either meshes or faces but not edges or vertices.
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: PathSelection.surfaceselect() behaviour?

Post by sliptonic »

Also, the allow_ORIG method appears to be dead code and unreachable.
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Re: PathSelection.surfaceselect() behaviour?

Post by agren »

I see. I'll make an attempt at a fix and a pull request.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: PathSelection.surfaceselect() behaviour?

Post by Kunda1 »

@agren any progress on issue #7207 ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Re: PathSelection.surfaceselect() behaviour?

Post by agren »

It's ready for review. Marking it as ready for review now.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: PathSelection.surfaceselect() behaviour?

Post by Kunda1 »

Thanks!. Pinged sliptonic to review PR.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: PathSelection.surfaceselect() behaviour?

Post by sliptonic »

The PR looks fine to me but is still marked 'draft'
Are you waiting on something? Remove the draft status and I'll merge.
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Re: PathSelection.surfaceselect() behaviour?

Post by agren »

Ah, just saw your comment on the PR and closed it with a comment. I'll look into whether bits of it can be salvaged if time allows.
Post Reply