Closed sigurHeBin closed 7 months ago
I suggest you use the builtin addon for dataexchange:
import sys
from OCC.Core.IGESControl import IGESControl_Reader
from OCC.Core.StlAPI import StlAPI_Writer
from OCC.Core.BRepMesh import BRepMesh_IncrementalMesh
from OCC.Extend.DataExchange import read_iges_file, write_stl_file
if len(sys.argv) != 3:
print("Usage: python iges_to_stl.py source.iges destination.stl")
sys.exit(1)
iges_file_path = sys.argv[1]
stl_file_path = sys.argv[2]
shape = read_iges_file(iges_file_path)
write_stl_file(shape, stl_file_path, mode="binary", linear_deflection=0.9, angular_deflection=0.5)
print(f"Converted IGES file {iges_file_path} to STL file {stl_file_path}")
Be careful with the deflection, if it's too low, you'll get a huge stl. Default values are a good start, the resulting stl file is 8.6Mb on my machine.
thanks for your relpy! I used your code to test and find some question.
I found ListIteratorOfListOfShape not in OCC.Core.TopTools, but in the OCC.Core.TopoDS
Maybe something went wrong when I was cmake the code. I modified the code and successfully converted the model after execution. My pythonocc-core version is 7.7.2 and My OCCT Version is 7.7.2 Thank you for your help!
Dear community: I've successfully deployed OCC and pythonocc-core on Linux, and I've written a script to convert an IGES format model to STL format. Although the script executed successfully, the original 15MB IGES model was reduced to a 4KB STL file. When I import the STL model into 3ds Max, the appearance of the model is completely different from the original. this is my python script:
this is my command: python3 /app/software/blender-python/export_iges_to_stl.py /app/software/blender-python/f16.IGS /app/software/blender-python/f16.stl
this is my test model: f16.zip
Could you help me figure out what could be causing this? I look forward to your reply, thank you!