united face after unify shapes

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

united face after unify shapes

Post by teobo »

Hello,
after unify the shapes are unified, but I want to have the faces as well unified?
Somebody an Idea?
tia

Here I make two default cubes and move one of them 1mm in z-direction for demonstration.

Code: Select all

App.newDocument("Unnamed")
App.setActiveDocument("Unnamed1")
App.ActiveDocument=App.getDocument("Unnamed1")
Gui.ActiveDocument=Gui.getDocument("Unnamed1")
Gui.activateWorkbench("PartWorkbench")
App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.ActiveObject.Label = "Cube"
App.ActiveDocument.recompute()
Gui.SendMsgToActiveView("ViewFit")
App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.ActiveObject.Label = "Cube"
App.ActiveDocument.recompute()
Gui.SendMsgToActiveView("ViewFit")
Gui.activateWorkbench("DraftWorkbench")
import Draft
Draft.move([FreeCAD.ActiveDocument.Box001],FreeCAD.Vector(0.0453453063965,-2.01303875446,0.0),copy=False)
FreeCAD.ActiveDocument.recompute()
Gui.activeDocument().activeView().viewTop()
import Draft
Draft.move([FreeCAD.ActiveDocument.Box],FreeCAD.Vector(0.0,0.0,-1.0),copy=False)
FreeCAD.ActiveDocument.recompute()
Gui.activateWorkbench("PartWorkbench")
App.activeDocument().addObject("Part::MultiFuse","Fusion")
App.activeDocument().Fusion.Shapes = [App.activeDocument().Box,App.activeDocument().Box001,]
Gui.activeDocument().Box.Visibility=False
Gui.activeDocument().Box001.Visibility=False
Gui.ActiveDocument.Fusion.ShapeColor=Gui.ActiveDocument.Box.ShapeColor
Gui.ActiveDocument.Fusion.DisplayMode=Gui.ActiveDocument.Box.DisplayMode
App.ActiveDocument.recompute()
len(App.ActiveDocument.Fusion.Shape.Faces)
14
# it is a box and a box has 6 sides not 14, right?
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: united face after unify shapes

Post by tanderson69 »

teobo wrote:len(App.ActiveDocument.Fusion.Shape.Faces)
14
# it is a box and a box has 6 sides not 14, right?
Not sure why you are getting 14. I am getting 12 from your script. Which makes sense from 2, 6 sides objects. Now why it is not 6 instead of 12, I am guessing you don't really want the following in your script:

Code: Select all

import Draft
Draft.move([FreeCAD.ActiveDocument.Box001],FreeCAD.Vector(0.0453453063965,-2.01303875446,0.0),copy=False)
FreeCAD.ActiveDocument.recompute()
Gui.activeDocument().activeView().viewTop()
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: united face after unify shapes

Post by teobo »

tanderson69 wrote:
teobo wrote:len(App.ActiveDocument.Fusion.Shape.Faces)
14
# it is a box and a box has 6 sides not 14, right?
Not sure why you are getting 14. I am getting 12 from your script. Which makes sense from 2, 6 sides objects. Now why it is not 6 instead of 12, I am guessing you don't really want the following in your script:

Code: Select all

import Draft
Draft.move([FreeCAD.ActiveDocument.Box001],FreeCAD.Vector(0.0453453063965,-2.01303875446,0.0),copy=False)
FreeCAD.ActiveDocument.recompute()
Gui.activeDocument().activeView().viewTop()
yes, exactly. After debugging a while I see that I messed things (like always :roll: ) in that demoscript. (i copied that well from the history)
6 faces plus 6 faces, together 14 faces. Thats ok, but in my case it simplifies a lot if the box gets back to six faces :?
...
Attachments
1.fcstd
(5.41 KiB) Downloaded 58 times
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: united face after unify shapes

Post by ickby »

the fusion does sometimes not remove some unneccessary edges, that is a occ issue. you can use the menu->part->refine command to remove the edges afterwards.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: united face after unify shapes

Post by NormandC »

In python, isn't the command called with removeSplitter() ?
tanderson69 should know. ;)
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: united face after unify shapes

Post by wmayer »

Yes, it's removeSplitter().
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: united face after unify shapes

Post by teobo »

normandc wrote:In python, isn't the command called with removeSplitter() ?
tanderson69 should know. ;)
Thanks ickby, Normand,

I found it in the codegeneration, which by the way proves how useful it is.
App.ActiveDocument.addObject('Part::Feature','Fusion').Shape=App.ActiveDocument.Fusion.Shape.removeSplitter()

And I still wonder where this functionality is (best) documented. Could need a tip.
If it is in occ have not found or do not know how to search for it.
And if it is within FreeCAD, the same do not know how to search for it (in the source code)

I found
https://github.com/mrlukeparry/freecad/ ... .cpp#L1802
and there I find:
ModelRefine::FaceUniter uniter(currentShell);

So here I loose track, is this (interface) part of occ, if not where occ comes in?

Tia
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: united face after unify shapes

Post by wmayer »

It's a self-written algorithm done by tanderson69. The method TopoShape::removeSplitter() checks the passed shape type and applies the algorithm to all shells inside this shape. The actual algorithm is implemented inside the class FaceUniter (see modelRefine.cpp)
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: united face after unify shapes

Post by tanderson69 »

normandc wrote:tanderson69 should know. ;)
I do. Sometimes I choose to respond to one aspect of a problem at a time. I was going to let him fix his script and then move on to the refinement. Besides, it leaves the low hanging fruit for you. :D
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: united face after unify shapes

Post by NormandC »

tanderson69 wrote:Besides, it leaves the low hanging fruit for you. :D
Considering how short my python legs are, I appreciate it! :D
Post Reply