coplanar face

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

coplanar face

Post by keithsloan52 »

I have a Face which has four vertex's vxy1 = [v1, v4, v3, v2, v1]
The values of V1 through to V4 are such that the Face is close to coplanar but is not coplanar such that trying to create a Face
produces an error
File "/Users/keithsloan/Library/Application Support/FreeCAD/Mod/GDML/./freecad/gdml/GDMLObjects.py", line 3448, in createGeometry
fxy1 = Part.Face(Part.makePolygon(vxy1))
<class 'Part.OCCError'>: Failed to create face from wire
Is there a good way to adjust values of the vertex such that the face is coplanar and does not produce an error.
Bearing in mind this is just one Face of the object so adjusting it will effect other faces.
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: coplanar face

Post by chrisb »

I see two possibilities using DatumPlanes:

1) Attach a DatumPlane to three points and project the fourth on the plane
2) Attach a DatumPlane with Inertia2-3 and map all points onto the plane.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: coplanar face

Post by dprojects »

keithsloan52 wrote: Tue Sep 27, 2022 11:25 am I have a Face which has four vertex's vxy1 = [v1, v4, v3, v2, v1]
The values of V1 through to V4 are such that the Face is close to coplanar but is not coplanar such that trying to create a Face
produces an error
File "/Users/keithsloan/Library/Application Support/FreeCAD/Mod/GDML/./freecad/gdml/GDMLObjects.py", line 3448, in createGeometry
fxy1 = Part.Face(Part.makePolygon(vxy1))
<class 'Part.OCCError'>: Failed to create face from wire
Is there a good way to adjust values of the vertex such that the face is coplanar and does not produce an error.
Bearing in mind this is just one Face of the object so adjusting it will effect other faces.
You may want to try:

Code: Select all

>>> help(Part.Vertex.isInside)
Help on method_descriptor:

isInside(...)
    Checks whether a point is inside or outside the shape.
    isInside(point, tolerance, checkFace) => Boolean
    --
    checkFace indicates if the point lying directly on a face is considered to be inside or not

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: coplanar face

Post by edwilliams16 »

keithsloan52 wrote: Tue Sep 27, 2022 11:25 am Bearing in mind this is just one Face of the object so adjusting it will effect other faces.
This is the key. You need to think through how you will adjust the vertices of each face so the process will come to an end. You can consider adjusting one vertex at a time so it is coplanar with the other three, or you can make the best-fit plane and adjust all four vertices.
Post Reply