Possible bug with Sketches and Boolean Fragments

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Possible bug with Sketches and Boolean Fragments

Post by openBrain »

jtm2020hyo wrote: Thu Jun 03, 2021 6:57 pm according to Part_Slice documentation, Boolean Fragments should splitter intersections
Seriously, I took time to quote the wiki and color the subshapes in my 1st reply.
Lattice2 Downgrade explodes each edge as being a single wire, but in your sketch subshapes, edges are grouped in wire objects, the latter being used by Boolean Fragments.
jtm2020hyo
Posts: 594
Joined: Wed Aug 12, 2020 1:24 am

Re: Possible bug with Sketches and Boolean Fragments

Post by jtm2020hyo »

ok, I think I understand now, Boolean Fragments Upgrade Sketch since Edges to Wires like this:

Image

...and Wire Object cannot be splitted by itself.

... maybe should be added in the future a new mode?

Image

I mean, choose between wires and edges
Attachments
SketcherBooleanPossibleBug3.FCStd
(32.15 KiB) Downloaded 45 times
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Possible bug with Sketches and Boolean Fragments

Post by openBrain »

jtm2020hyo wrote: Fri Jun 04, 2021 2:24 am ok, I think I understand now, Boolean Fragments Upgrade Sketch since Edges to Wires like this:

...and Wire Object cannot be splitted by itself.
That's it, except that there is no upgrade there. Boolean Fragments uses subshapes obtained by '.Shape.SubShapes' property, whatever could be the object type. In a sketch, these are wires.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Possible bug with Sketches and Boolean Fragments

Post by paullee »

jtm2020hyo wrote: Fri Jun 04, 2021 2:24 am ok, I think I understand now, Boolean Fragments Upgrade Sketch since Edges to Wires like this:
...and Wire Object cannot be splitted by itself.
... maybe should be added in the future a new mode?
I tried Boolean Fragments similarly on a floor plan, but turn to use edge.cut(edge). Further test and study of the original code:

Code: Select all

class FeatureBooleanFragments:
...
    def execute(self,selfobj):
        shapes = [obj.Shape for obj in selfobj.Objects]
        if len(shapes) == 1 and shapes[0].ShapeType == "Compound":
            shapes = shapes[0].childShapes()
  1. May test if it is a Sketch, use its Edges of Wires instead of Wires?
  2. May test if it is a Wire (Sketch or DraftWire), use its Edges, so 'self-interesting' case still support
  3. Would be handy if above is supported, more intuitive for users. Pseudo-code:

    Code: Select all

            if len(shapes) == 1 and shapes[0].ShapeType == "Compound"  (and test if it is a Sketch):
                shapes = [ grandchildShapes for childShapes in shapes[0].childShapes() ] 
                ## i.e. use their Edges instead of Wires
            elif len(shapes) == 1 and shapes[0].ShapeType == "Wire":
            ## still works if Sketch contain only 1 Wires with many Edges
                shapes = shapes[0].childShapes()
    
DeepSOIC wrote: Sun Sep 03, 2017 1:32 pm ping
Should this be supported? Thanks :)

Test_ BooleanFragmentFeature.FCStd
(9.45 KiB) Downloaded 58 times
Screenshot from 2021-06-05 02-09-33.png
Screenshot from 2021-06-05 02-09-33.png (225.22 KiB) Viewed 2799 times
jtm2020hyo
Posts: 594
Joined: Wed Aug 12, 2020 1:24 am

Re: Possible bug with Sketches and Boolean Fragments

Post by jtm2020hyo »

openBrain wrote: Fri Jun 04, 2021 4:51 am
That's it, except that there is no upgrade there. Boolean Fragments uses sub shapes obtained by 'Shape.SubShapes' property, whatever could be the object type. In a sketch, these are wires.
This is a bit confusing because when we use Sketcher WB we draw Edges and Points, we are not aware that Objects are interpreted as Wires Objects.

... The user needs more control because, if not, we will have a lot of unexpected fails.

... I mean some options to control Sketcher WB like converting our Edges Objects to Wires Objects (like Bspline), and Wires Objects to Faces Objects inside Sketcher. Many other External WB has problems with this.

... Also, Part_Fragments probably not just generate unexpected results with Wires being Spltting by itself, is sure that this happen also with non-coplanar Faces and Solids like toroids. And maybe not just Part_Fragments, maybe other like Part Fusion or Part Intersection, Etc.
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: Possible bug with Sketches and Boolean Fragments

Post by chrisb »

jtm2020hyo wrote: Sat Jun 05, 2021 12:15 am ... The user needs more control because, if not, we will have a lot of unexpected fails.

... I mean some options to control Sketcher WB like converting our Edges Objects to Wires Objects (like Bspline), and Wires Objects to Faces Objects inside Sketcher. Many other External WB has problems with this.
You are heavily exaggerating here. I have probably seen thousands of quite different models, and this was never ever a problem, and there was not a single unexpected fail.
I also don't see the many other workbenches having problems with the current behaviour.

Your use case seems to me rather a very rare corner case, and I think it is acceptable that some more user interaction is required to make it behave as you expect.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Possible bug with Sketches and Boolean Fragments

Post by paullee »

chrisb wrote: Sat Jun 05, 2021 5:07 am I also don't see the many other workbenches having problems with the current behaviour.
Indeed current behaviour is good for current use :)

It happens what @jtm2020hyo expects has something common in the discussion [Feature] Drawing Walls = Drawing Rooms Automatically . I started to use Boolean Fragments, probably similar to @jtm2020hyo, just later I use edge.cut(edges) to overcome what currently do not support.

This maybe something that Boolean Fragment can extend its usage, as in pseudo-code being conceived above. And somehow more intuitive to match some corner case users expectation.
DeepSOIC wrote: Sun Sep 03, 2017 1:32 pm ping
BTW, as currently Wires formed by Sketch would not cut itself, it maybe good to add this remark in the Wiki :)

Thanks.
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Possible bug with Sketches and Boolean Fragments

Post by onekk »

jtm2020hyo wrote: Sat Jun 05, 2021 12:15 am This is a bit confusing because when we use Sketcher WB we draw Edges and Points, we are not aware that Objects are interpreted as Wires Objects.

What is confusing?

You draw points and edges, but it is treated like a whole object, and you want that your sketch is treated as a whole object if not there are no "continuity" and no way to create faces, and other things.

Summarizing, You are saying that is strange that a wire is composed by point and edges (actually, they are edges only as a point has no space it's a point).

It is strange the opposite.

It is not hidden nor confusing is the way "things are done".

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Possible bug with Sketches and Boolean Fragments

Post by DeepSOIC »

paullee wrote: Fri Jun 04, 2021 6:24 pm

Code: Select all

if len(shapes) == 1 and shapes[0].ShapeType == "Compound"  (and test if it is a Sketch):
            shapes = [ grandchildShapes for childShapes in shapes[0].childShapes() ] 
            ## i.e. use their Edges instead of Wires
And how do i proceed if i actually want to intersect wires of the sketch, not its edges?

If you don't mind using Lattice2, this can be easily taken care of by applying Lattice Downgrade To Edges before BooleanFragments. Bringing the tool into main FreeCAD seems like a good idea.

Sorry guys, i'm not contributing to freecad lately, just don't feel like it, i'm having fun with other stuff.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Possible bug with Sketches and Boolean Fragments

Post by paullee »

DeepSOIC wrote: Sat Jun 05, 2021 5:11 pm If you don't mind using Lattice2, this can be easily taken care of by applying Lattice Downgrade To Edges before BooleanFragments. Bringing the tool into main FreeCAD seems like a good idea.

Sorry guys, i'm not contributing to freecad lately, just don't feel like it, i'm having fun with other stuff.
Thanks for the hint. The Lattice2 wb seems powerful, hope the OP find this workflow useful :)

Enjoy and look forward for contribution in the future!
Post Reply