首页 > 解决方案 > stl_writer.Write 不保存任何文件

问题描述

我正在尝试从 stp 转换为 stl。代码是:

rom OCC.Core.STEPControl import STEPControl_Reader
from OCC.Core.StlAPI import StlAPI_Writer
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))


input_file  = 'stl_test.stp'   # input STEP (AP203/AP214 file)
output_file = 'stl_test.stl'   # output X3D file


step_reader = STEPControl_Reader()
step_reader.ReadFile( input_file )
step_reader.TransferRoot()
myshape = step_reader.Shape()
print("File readed")

# Export to STL
stl_writer = StlAPI_Writer()
stl_writer.SetASCIIMode(True)
stl_writer.Write(myshape, output_file)
print(stl_writer.Write(myshape, output_file))
print("Written")

这不会在工作目录中保存任何内容。并print(stl_writer.Write(myshape, output_file))给出错误的输出。

任何人都可以帮忙吗?

标签: pythonpythonocc

解决方案


推荐阅读