How to create a face/surface from the points

Hello Everyone,
I am very new to OpenCascade and also have basic knowledge of CAD: I am using PyOCC for modeling simple surfaces from the points.
I was trying to convert the points into faces. Below is the code I have written. I dont know where I am going wrong.Can anyone help me with this.
from OCC.Core.gp import gp_Pnt
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakePolygon, BRepBuilderAPI_MakeFace
from OCC.Display.SimpleGui import init_display
from OCC.Core.IGESControl import IGESControl_Controller, IGESControl_Writer

pnt1=gp_Pnt(17.0009151031289, 0.000688963126647295,179.56046109071)
pnt2=gp_Pnt(17.0000076318359, 5.12467434038162, 179.560570403242)
pnt3=gp_Pnt(17.0214072627106, 5.1394943066424,179.705691846314 )
pnt4=gp_Pnt(17.0223391626952, 0.0155338588384938, 179.705668497673)

poly = BRepBuilderAPI_MakePolygon(pnt1, pnt2, pnt3, pnt4, True).Wire()

face= BRepBuilderAPI_MakeFace(poly).Face()

iges_writer = IGESControl_Writer()
status = iges_writer.AddShape(face)
if status: # If the shape was added successfully
file_path = "PATH" # Define the file path
iges_writer.Write(file_path)

# Visualize the surface using OCC's display
display, start_display, _, _ = init_display()
display.DisplayShape(face, update=True)
start_display()
print(f"Surface saved to {file_path}")
else:
print("Failed to add shape to IGES file.")

Dmitrii Pasukhin's picture

Hello, IGES can't export mesh. Available formats for export: STEP, GLTF, OBJ, STL, VRML.

The best option is to create Poly_Triangulation(not polygon). If you would like to have geometry - you need to create a BSpline.

Best regards, Dmitrii.

Vivek Shivasagara Vijay's picture

Hello Mr. Pasukhin,
Thanks for your suggestion. It worked with BSpline.

Regards,
Vivek

Dmitrii Pasukhin's picture

In this case I recommend to use "GeomAPI_PointsToBSplineSurface"

Best regards, Dmitrii.

Vivek Shivasagara Vijay's picture

Hello Mr. Pasukhin,
I have created a face based on ypur suggestion. Below is the code for the same.
p1 = gp_Pnt(17.0009151031289, 0.000688963126647295, 179.56046109071)
p2 = gp_Pnt(17.0000076318359, 5.12467434038162, 179.560570403242)
p3 = gp_Pnt(17.0214072627106, 5.1394943066424, 179.705691846314)
p4 = gp_Pnt(17.0223391626952, 0.0155338588384938, 179.705668497673)
array = TColgp_Array2OfPnt(1, 2, 1, 2)
array.SetValue(1, 1, p1)
array.SetValue(2, 1, p2)
array.SetValue(1, 2, p4)
array.SetValue(2, 2, p3)
curve = GeomAPI_PointsToBSplineSurface(array, 3, 8, GeomAbs_C2, 0.001).Surface()
face = BRepBuilderAPI_MakeFace(curve, 1e-6).Face()
I have multiple faces like this,and i use sewing operation to make these faces into a sewed shape. Now i want to convert this into solid and add thicknees to complete shape.But before that do i need to make this as a shell? Do you have any suggestions how to proceed?

Regards,
Vivek Shivasagara Vijay