I found a solution, using topology, as you have common edges:
The point is to use the BREP paaradigm, although many thinks wrong that part is only CSG (see Wikipedia for difference between them), Part WB have all the machinery to make BREP surfaces.
Following topology:
- A wire is made of egdes
- A face is made "filling" closed wires
- A shell is made of faces
- A solid is a "portion of 3d space" include in a closed shell, read may "watertight" or "manifold" as terminology is shared between meshed sometimes
So you have already two wires, not difficult to obtain, using "only" Part WB:
Code: Select all
wire11 = Part.makePolygon([p11, p12, p14, p11])
# Part.show(wire11, "wire11")
wire12 = Part.makePolygon([p11, p13, p14, p11])
# Part.show(wire12, "wire12")
Not too difficult, note the repetition of the starting point to obtain a closed polygon
To obtain faces is not very difficult:
Code: Select all
face11 = Part.Face(wire11)
face12 = Part.Face(wire12)
Now you have to create the two "missing" faces, so following again topology:
Code: Select all
edge11 = Part.LineSegment(p11, p12).toShape()
edge12 = Part.LineSegment(p11, p13).toShape()
edge13 = Part.LineSegment(p13, p12).toShape()
surf1 = Part.makeFilledFace([edge11, edge12,edge13])
# Part.show(surf1, "surface1")
This will supply a list of edges and if they are closed the method
Part.makeFilledFace will do the job.
Same for the other face.
Now the Shell and the solid:
Code: Select all
shell1 = Part.Shell([face11, face12, surf1, surf2])
Part.show(shell1, "shell1")
solid1 = Part.Solid(shell1)
Part.show(solid1, "solid1")
Not very difficult, and usually it works, but if you create some "non closed", "non manifold" or "non watertight" shells, the solid could not be created.
The code is left as an educational code, as it shows a couple of techniques to make faces, you could have created all the
edges and compose individually faces using
Part.makeFilledFace as example, or used the
Part.makePolygon and then transform the wire in a Face.
You could use:
to obtain info about methods in the "python Console" fairly easily, probably doing:
could solve some problems that may arise as not everytime Part is imported in FC explicitly.
Code is more verbose as it uses some "helper methods" to make thing easier, as at every run it "empty the document" and fill it with new objects.
Plus some imports in the code:
Code: Select all
from FreeCAD import Placement, Rotation, Vector # noqa
Will explicitly expose many construct that will short writing.
note that:
Code: Select all
Part.LineSegment(p11, p12).toShape()
could create some conceptual problems, if you have not cacth the inner working of FC:
Alone will return a
"Curve" i.e a "Geometry object" that have not a
Shape so the
.toShape() to obtain a Shape that could be used as an
Edge
more on:
Document Objects
https://wiki.freecadweb.org/App_DocumentObject
TopoShapes
https://wiki.freecadweb.org/Part_TopoShape
Some geometry and topology consideration (with some code):
https://forum.freecadweb.org/viewtopic. ... 55#p484455
https://forum.freecadweb.org/viewtopic. ... 89#p500989
https://forum.freecadweb.org/viewtopic. ... 11#p463511
Tested on:
Code: Select all
OS: Artix Linux (openbox)
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20)
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.9.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: Italian/Italy (it_IT)
Installed mods:
* Curves 0.5.2
Hope it helps
Regards
Carlo D.