Python中的STEP文件读取问题

时间:2015-01-24 12:53:01

标签: python-3.x step

我正在使用Python3.4.2和pythonOCC-0.16.0-win32-py34.exe来绘制组件。每个组件都使用一种定义的颜色正确渲染,但看起来不像现实世界的组件。

enter image description here 上图是我的Python实现,它使用一种颜色从STEP文件生成3D图像。

下面的图片呈现了我的一个Windows软件,我在那里使用了Step文件。我想渲染组件与下图中的外观相同,因此它看起来像一个真实的组件。

enter image description here

有没有办法通过读取STEP文件在Python中获得正确的彩色输出?我搜索了很多,但没有办法实现它。请帮助我前进。

from future import print_function
import sys
#from OCC.STEPCAFControl import STEPCAFControl_Reader
from OCC.STEPControl import STEPControl_Reader
from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity
from OCC.Display.SimpleGui import init_display
from OCC.Display.WebGl import threejs_renderer

step_reader = STEPControl_Reader()
status = step_reader.ReadFile('./models/test.STEP')

if status == IFSelect_RetDone: # check status
failsonly = False
step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)
step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)

ok = step_reader.TransferRoot(1)
_nbs = step_reader.NbShapes()
aResShape = step_reader.Shape(1)
else:
print("Error: can't read file.")
sys.exit(0)

#display, start_display, add_menu, add_function_to_menu = init_display()
#display.DisplayShape(aResShape, update=True)
#start_display()

my_renderer = threejs_renderer.ThreejsRenderer(background_color="#123345")
my_renderer.DisplayShape(aResShape)

以上代码用于使用Python读取STEP文件。

0 个答案:

没有答案
相关问题