PythonOCC 3D图形库学习—导入STEP模型
2016-03-04 13:44
363 查看
PythonOCC comes with importers/exporters for the most commonly used standard data files format in engineering: STEP, IGES, STL (ascii/binary) and VRML. After the import is successfull, the resulting shape can be handled as a native topology/geometry, i.e. you can use boolean operations, shape fixing, traverse topology etc. PythonOCC中含有导入/导出模块,可以处理STEP,IGES,STL等格式的CAD模型.
STEP file is a CAD file format, usually used to share 3D models between users with different CAD systems. CAD file interchangeability is a huge, huge headache in the field, so it has to be make uniform. Standard ISO 10303 is trying to solve this problem. This standard is informally known as “STEP”, which stands for “Standard for the Exchange of Product model data”. STEP-file (ISO 10303-21) is implementation method of STEP standard that can represent 3D object in Computer-aided design (CAD) and related information.
各种CAD软件一般都使用自己定义的格式存储模型,因此造成数据交换困难,比如在UG里面创建的三维模型不能直接导入到Solidworks中。因此CAD数据交换标准之一的STEP格式被制定出来,使用任何的主流三维设计软件Peo/E、UG、CATIA、Solidworks等都可以直接打开STEP格式的文件(*.step, *.stp)
下面使用PythonOCC导入飞行器STEP格式的三维模型并显示出来(模型下载网址:https://grabcad.com/library):
苏30:
F-22 猛禽:
大疆phantom3:
参考:
http://www.opencascade.com/doc/occt-6.9.1/overview/html/occt__tutorial.html
http://www.opencascade.com/doc/occt-6.9.0/refman/html/class_s_t_e_p_control___reader.html
STEP file is a CAD file format, usually used to share 3D models between users with different CAD systems. CAD file interchangeability is a huge, huge headache in the field, so it has to be make uniform. Standard ISO 10303 is trying to solve this problem. This standard is informally known as “STEP”, which stands for “Standard for the Exchange of Product model data”. STEP-file (ISO 10303-21) is implementation method of STEP standard that can represent 3D object in Computer-aided design (CAD) and related information.
各种CAD软件一般都使用自己定义的格式存储模型,因此造成数据交换困难,比如在UG里面创建的三维模型不能直接导入到Solidworks中。因此CAD数据交换标准之一的STEP格式被制定出来,使用任何的主流三维设计软件Peo/E、UG、CATIA、Solidworks等都可以直接打开STEP格式的文件(*.step, *.stp)
下面使用PythonOCC导入飞行器STEP格式的三维模型并显示出来(模型下载网址:https://grabcad.com/library):
''' You can translate a STEP file into an OCCT shape in the following steps: 1.load the file, 2.check file consistency, 3.set the translation parameters, 4.perform the translation, 5.fetch the results. ''' import sys from OCC.Display.SimpleGui import init_display from OCC.IFSelect import IFSelect_RetDone,IFSelect_ItemsByEntity # Reads STEP files, checks them and translates their contents into Open CASCADE models from OCC.STEPControl import STEPControl_Reader # Creates a reader object with an empty STEP mode step_reader = STEPControl_Reader() # Loads a file and returns the read status status = step_reader.ReadFile('Drone.step') # check status if status == IFSelect_RetDone: # RetDone : normal execution with a result # Checking the STEP file # Error messages are displayed if there are invalid or incomplete STEP entities step_reader.PrintCheckLoad(True, IFSelect_ItemsByEntity) # Performing the STEP file translation step_reader.TransferRoot() # Each successful translation operation outputs one shape # Returns the shape resulting from a translation shape = step_reader.Shape() else: print("Error: can't read file.") sys.exit(0) # initializes the display display, start_display, add_menu, add_function_to_menu = init_display() # Then the shape is sent to the renderer display.DisplayShape(shape, update=True) # enter the gui mainloop start_display()
苏30:
F-22 猛禽:
大疆phantom3:
参考:
http://www.opencascade.com/doc/occt-6.9.1/overview/html/occt__tutorial.html
http://www.opencascade.com/doc/occt-6.9.0/refman/html/class_s_t_e_p_control___reader.html
相关文章推荐
- python scikit-learn 安装中的各种事宜
- python __init__.py
- python的类方法和静态方法
- 杂记(python)
- Python 拆分字符串
- Python正则表达式的七个使用范例
- python学习笔记一
- 第一个Python程序
- 《笨办法学Python》 总结
- python 汉字编码问题,请大神帮忙!!
- python 类里面的单下划线与双下划线的区别(私有和保护) .
- Python推荐书籍
- python解析html
- 安装Python
- python正则表达式中的match 和 search
- Python简介
- arcgis10.3 python2.7 开发环境配置
- python round()方法
- python os.execl记录下遇到的传参问题
- python中__name__的使用