wmayer wrote: ↑Sun Aug 07, 2022 1:35 pm
Could you please advise me on how to use the methods to trim the obtained surface.
The four boundary curves do not exactly lie on the face. So, in a first step you must project them onto the surface. And then you can create a surface from the four boundary edges and the given face as support surface.
Another possibility is to create a filled face from the boundary edges, extrude it to create a solid and then perform a boolean intersection.
...
Ok thanks, now it works, using the following code:
Code: Select all
import FreeCAD
from FreeCAD import Base, Rotation, Vector # noqa
import Part
def test_platesurface():
"""From testcode."""
v1 = Vector(0,0,0)
v2 = Vector(10,0,0)
v3 = Vector(10,10,3)
v4 = Vector(0,10,0)
v5 = Vector(5,5,5)
l1 = Part.LineSegment(v1, v2)
l2 = Part.LineSegment(v2, v3)
l3 = Part.LineSegment(v3, v4)
l4 = Part.LineSegment(v4, v1)
c1 = Part.GeomPlate.CurveConstraint(l1)
c2 = Part.GeomPlate.CurveConstraint(l2)
c3 = Part.GeomPlate.CurveConstraint(l3)
c4 = Part.GeomPlate.CurveConstraint(l4)
c5 = Part.GeomPlate.PointConstraint(v5)
bp = Part.GeomPlate.BuildPlateSurface()
bp.add(c1)
bp.add(c2)
bp.add(c3)
bp.add(c4)
bp.add(c5)
bp.perform()
s = bp.surface()
bs = s.makeApprox()
# Part.show(bs.toShape())
# Part.show(l1.toShape())
# Part.show(l2.toShape())
# Part.show(l3.toShape())
# Part.show(l4.toShape())
bp.surfInit()
face = bs.toShape()
wire = Part.Wire([l1.toShape(), l2.toShape(), l3.toShape(), l4.toShape()])
comp = face.project([wire])
face_from_proj_wire = Part.makeFilledFace(comp.Edges)
solid = face_from_proj_wire.extrude(App.Vector(0,0,10))
solid.Placement.Base.z = -5
trimmed_face = solid.common(face)
Part.show(trimmed_face, "trim_surface")
A little question:
- what it the scope of:
Help says that it "returns the initial surface" but being assigned to a variable, I don't guess what is the scope.
EDIT:
Reading this description:
https://dev.opencascade.org/doc/occt-7. ... plate.html
I've thought that supplying the initial surface to "deform" using constraints, I will obtain something more regular, that is near the point cloud, but I obtain this:
- geomplate1.png (23.58 KiB) Viewed 693 times
- geomplate2.png (2.39 KiB) Viewed 693 times
- geomplate3.png (5.85 KiB) Viewed 693 times
This is the code elaborate some more and probably simplified a little, The initial definition of the bspline is using many lines.
Regards
Carlo D.