Trying to export STL file in python demos #913
-
Hello Sir, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for opening an issue here! I will move this issue to the discussion board if you don't mind. I think this demo could help you along: https://github.com/rainman110/tigl-workshop/blob/master/Exercises/solutions/Exercise1_Basics_Solution.ipynb. Basically, you would use pythonocc to create a from tigl3 import curve_factories as cf
from tigl3 import surface_factories as sf
from tigl3.exports import create_exporter
from tigl3.geometry import CNamedShape
from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeFace
# list of points on NACA2412 profile
px = [1.000084, 0.975825, 0.905287, 0.795069, 0.655665, 0.500588, 0.34468, 0.203313, 0.091996, 0.022051, 0.0, 0.026892, 0.098987, 0.208902, 0.346303, 0.499412, 0.653352, 0.792716, 0.90373, 0.975232, 0.999916]
py = [0.001257, 0.006231, 0.019752, 0.03826, 0.057302, 0.072381, 0.079198, 0.072947, 0.054325, 0.028152, 0.0, -0.023408, -0.037507, -0.042346, -0.039941, -0.033493, -0.0245, -0.015499, -0.008033, -0.003035, -0.001257]
# lists of coordinates for 2 curves
points1 = []
points2 = []
for x, y in zip(px, py):
points1.append([x*100, y*100, 0])
points2.append([x*100, y*100, 500])
curve1 = cf.interpolate_points(points1)
curve2 = cf.interpolate_points(points2)
surface = sf.interpolate_curves([curve1, curve2])
face = BRepBuilderAPI_MakeFace(surface, 1e-6).Face()
named_face = CNamedShape(face, "myface")
stl_exporter = create_exporter("stl")
stl_exporter.add_shape(named_face)
stl_exporter.write("test.stl") |
Beta Was this translation helpful? Give feedback.
Thanks for opening an issue here! I will move this issue to the discussion board if you don't mind.
I think this demo could help you along: https://github.com/rainman110/tigl-workshop/blob/master/Exercises/solutions/Exercise1_Basics_Solution.ipynb.
Basically, you would use pythonocc to create a
TopoDS_Face
from yourGeom_BSplineSurface
. Then you can pass this face to aCNamedShape
. The latter is a tigl class that can be added to an exporter: