split face (into window,wand) and reintegrate them in solid

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

split face (into window,wand) and reintegrate them in solid

Post by teobo »

Hi,
already asked a similar thing on the freecad gui help forum, now I realize that is it more a Python scripting issue.

So say there is for example a cube with 6 faces. I want to have a cube of ít with 7 faces, whereas one face figures as a window in one of the remaining 6 faces. Simple, is not it?

How do I do this?
0.So I explode the original cube.
1.And then I take one face and by some manipulation I make two of it. One (2D) window and one 2(2D)-Wand,
2.and rebuild the solid out of it.

How can I acchieve 1. or. 2. in Freecad? And overmore, is that feasible in Freecad?
Tia
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: split face (into window,wand) and reintegrate them in so

Post by teobo »

to clarify point 1.
I would like to construct such a face by script:


One other idea: Could it be, that the solution lies behind: Part.Face() or to say in the opencascade side of the code, the wrapper maybe is not well enough documented and it is unprobable that anybody of the freecaders knows about that.
Evidently the code can produce such faces, as the high level function pocket shows, does not it?

Then: should one search better in opencascade for an interface and how to use it?
tia

Update
Now I found:
viewtopic.php?f=22&t=5376#p43034
..pass a list of several wires then the first wire is used to create the face and the further wires describe holes in this face
I testet it and it works fine.

Now next Problem:
How do I position the hole-wire in the plane within the outer wire? Any ideas?
Attachments
windowface140411.fcstd
(2.58 KiB) Downloaded 65 times
windowface.PNG
windowface.PNG (3.38 KiB) Viewed 3912 times
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: split face (into window,wand) and reintegrate them in so

Post by teobo »

Hello,
made several tests besides described in the below code for demostrate the error. Result: bore face not working.
Think this is bug reportable.
Bye

Code: Select all

#tests:W7 13 Part.Face from wire: triangle  to outer corner, dwire:no
#                 drawn rectangle: triangle  to outer cornerss.
#tests:W7 14 Part.Face from wire: triangle  to outer corners
#                 makeFilledFace :No
#                 upgrade: No


#close and new doc
App.closeDocument(App.ActiveDocument.Name);
App.newDocument("Unnamed");Gui.activateWorkbench("DraftWorkbench")

import Draft
points=[FreeCAD.Vector(-3.40705227852,0.624237239361,0.0),FreeCAD.Vector(-3.32537651062,-0.822593152523,0.0),FreeCAD.Vector(-2.13524150848,-0.857597053051,0.0),FreeCAD.Vector(-2.22858548164,0.635905325413,0.0)]
a=Draft.makeWire(points,closed=True,face=False,support=None)
points1=[FreeCAD.Vector(-3.15035629272,0.157517880201,0.0),FreeCAD.Vector(-3.06868076324,-0.519225478172,0.0),FreeCAD.Vector(-2.5086171627,-0.53089338541,0.0),FreeCAD.Vector(-2.62529706955,0.0991778969765,0.0)]
b=Draft.makeWire(points1,closed=True,face=False,support=None)


Draft.move([b],FreeCAD.Vector(0.0,0.0,0.0),copy=False)
Draft.downgrade(FreeCADGui.Selection.getSelection(),delete=True)
b=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]

Draft.move([b],FreeCAD.Vector(0.0,0.0,0.0),copy=False)
Draft.downgrade(FreeCADGui.Selection.getSelection(),delete=True)
b=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]

Draft.move([a],FreeCAD.Vector(0.0,0.0,0.0),copy=False)
Draft.downgrade(FreeCADGui.Selection.getSelection(),delete=True)
a=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]

Draft.move([a],FreeCAD.Vector(0.0,0.0,0.0),copy=False)
Draft.downgrade(FreeCADGui.Selection.getSelection(),delete=True)
a=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]

#in w7 013 no downgrade
#b=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-2]
#a=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]

App.ActiveDocument.recompute
t=Part.Face([a.Shape,b.Shape])
Part.show(t)

App.ActiveDocument.recompute()
c=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]

t=Part.Face([b.Shape,a.Shape])
Part.show(t)
d=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]
Gui.getDocument("Unnamed").getObject("Wire").Visibility=False
Gui.getDocument("Unnamed").getObject("Wire001").Visibility=False
####
#polygon = Part.makePolygon(points)
#polygon1 = Part.makePolygon(points1)

#polygonf = Part.Face(polygon)
#polygonf1 = Part.Face(polygon1)
#t=Part.Face([polygon,polygon1])
#Part.show(t)
#Part.show(polygonf)
Attachments
holeface_isolated_points140412Windows_0.13.PNG
holeface_isolated_points140412Windows_0.13.PNG (25.66 KiB) Viewed 3894 times
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: split face (into window,wand) and reintegrate them in so

Post by teobo »

http://www.freecadweb.org/tracker/view.php?id=1510

workaround:Shape.cut

Code: Select all

#close and new doc
App.closeDocument(App.ActiveDocument.Name);
App.newDocument("Unnamed");Gui.activateWorkbench("DraftWorkbench")
import Draft
points=[FreeCAD.Vector(-3.40705227852,0.624237239361,0.0),FreeCAD.Vector(-3.32537651062,-0.822593152523,0.0),FreeCAD.Vector(-2.13524150848,-0.857597053051,0.0),FreeCAD.Vector(-2.22858548164,0.635905325413,0.0)]
a=Draft.makeWire(points,closed=True,face=False,support=None)
DWire=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]
points1=[FreeCAD.Vector(-3.15035629272,0.157517880201,0.0),FreeCAD.Vector(-3.06868076324,-0.519225478172,0.0),FreeCAD.Vector(-2.5086171627,-0.53089338541,0.0),FreeCAD.Vector(-2.62529706955,0.0991778969765,0.0)]
b=Draft.makeWire(points1,closed=True,face=False,support=None)
DWire001=App.ActiveDocument.Objects[len(App.ActiveDocument.Objects)-1]

diff=DWire.Shape.cut(DWire001.Shape)
Part.show(diff)
#bore
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: split face (into window,wand) and reintegrate them in so

Post by teobo »

http://www.freecadweb.org/tracker/view. ... 1510#c4568
Here is the solution. Thanks for that wandererfan
In the script pcb.py there is a

Code: Select all

w2 = r2.Shape.OuterWire
w2.reverse()                     # make w2 an inside contour
applied to the inner wire. I had read something like that in occ's forum.
One needs to study the occ interface. At this point at least I do not know where to get this peace of infomation. Maybe someone could put such a hint in the wiki.
Post Reply