博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PythonOCC 3D图形库学习—导入STEP模型
阅读量:6305 次
发布时间:2019-06-22

本文共 2704 字,大约阅读时间需要 9 分钟。

PythonOCC comes with importers/exporters for the most commonly used standard data files format in engineering: , 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格式的三维模型并显示出来(模型下载网址:):

1 ''' 2 You can translate a STEP file into an OCCT shape in the following steps: 3  1.load the file, 4  2.check file consistency, 5  3.set the translation parameters, 6  4.perform the translation, 7  5.fetch the results. 8 ''' 9 10 import sys11 from OCC.Display.SimpleGui import init_display12 from OCC.IFSelect import IFSelect_RetDone,IFSelect_ItemsByEntity13 14 # Reads STEP files, checks them and translates their contents into Open CASCADE models15 from OCC.STEPControl import STEPControl_Reader16 17 18 # Creates a reader object with an empty STEP mode19 step_reader = STEPControl_Reader()20 21 # Loads a file and returns the read status22 status = step_reader.ReadFile('Drone.step')23 24 # check status 25 if status == IFSelect_RetDone:  # RetDone : normal execution with a result26     # Checking the STEP file27     # Error messages are displayed if there are invalid or incomplete STEP entities28     step_reader.PrintCheckLoad(True, IFSelect_ItemsByEntity)29 30     # Performing the STEP file translation31     step_reader.TransferRoot()32 33     # Each successful translation operation outputs one shape34     # Returns the shape resulting from a translation35     shape = step_reader.Shape()36 else:37     print("Error: can't read file.")38     sys.exit(0)39           40 # initializes the display41 display, start_display, add_menu, add_function_to_menu = init_display()42 43 # Then the shape is sent to the renderer44 display.DisplayShape(shape, update=True)45 46 # enter the gui mainloop47 start_display()

苏30:

F-22 猛禽:

大疆phantom3:

 

参考:

转载于:https://www.cnblogs.com/21207-iHome/p/5241833.html

你可能感兴趣的文章
大数据技术现状
查看>>
第 17 章 Process
查看>>
[20150513]函数索引与CURSOR_SHARING=FORCE
查看>>
mongodb系列02-------深入理解索引原理
查看>>
文件句柄设置
查看>>
[Aaronyang] 写给自己的WPF4.5 笔记15[AyArc诞生-WPF版本绚丽的环状图,Ay制作,AyWindow强势预览]...
查看>>
诗词—《蝶恋花·相思何谓情》
查看>>
SharePoint 2013 安装图解
查看>>
本周不容错过的的9篇NLP论文 | PaperDaily #21
查看>>
各种加密解密函数(URL加密解密、sha1加密解密、des加密解密)
查看>>
js下来数据填充
查看>>
Flink运行时之统一的数据交换对象
查看>>
《Master Opencv...读书笔记》非刚性人脸跟踪 III
查看>>
优秀开源项目之三:高性能、高并发、高扩展性和可读性的网络服务器架构State Threads...
查看>>
Docker推出了Docker云,给大家介绍下哈!
查看>>
Vagrant+virtualBox搭建集成开发环境
查看>>
谈谈Spark与Spark-Streaming关系
查看>>
【数学题】新倍数问题
查看>>
java-计数器
查看>>
Penguin借高性能计算走向云世界
查看>>