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):

 '''
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

PythonOCC 3D图形库学习—导入STEP模型的更多相关文章

  1. PythonOCC 3D图形库学习—创建立方体模型

    Open CASCADE(简称OCC)平台是是一个开源的C++类库,OCC主要用于开发二维和三维几何建模应用程序,包括通用的或专业的计算机辅助设计CAD系统.制造或分析领域的应用程序.仿真应用程序或图 ...

  2. PV3D学习笔记-导入DAE模型

      网上关于PV3D导入DAE模型的例子都非常多,可惜我研究了半天,一个都没成功,或者是破面问题,或者是贴图不显示,再或者贴图乱掉了.今天晚上终于搞定,心得发上来. 制作模型的软件是SketchUp ...

  3. Unity 3d导入3dMax模型 产生若干问题

    Unity 3d导入3dMax模型 会产生若干问题,按照官方 的说明,将max 模型导成fbx文件 导入untiy似乎也不能解决 1.x轴向偏转3dmax模型导入后自动有一个x轴270度的偏转,巧合的 ...

  4. Unity3D游戏开发从零单排(五) - 导入CS模型到Unity3D

    游戏动画基础 Animation组件 Animation组件是对于老的动画系统来说的. 老的动画形同相应的动画就是clip,每一个运动都是一段单独的动画,使用Play()或CrossFade(),直接 ...

  5. 用scikit-learn学习LDA主题模型

    在LDA模型原理篇我们总结了LDA主题模型的原理,这里我们就从应用的角度来使用scikit-learn来学习LDA主题模型.除了scikit-learn,  还有spark MLlib和gensim库 ...

  6. ICML 2018 | 从强化学习到生成模型:40篇值得一读的论文

    https://blog.csdn.net/y80gDg1/article/details/81463731 感谢阅读腾讯AI Lab微信号第34篇文章.当地时间 7 月 10-15 日,第 35 届 ...

  7. 使用keras导入densenet模型

    从keras的keras_applications的文件夹内可以找到内置模型的源代码 Kera的应用模块Application提供了带有预训练权重的Keras模型,这些模型可以用来进行预测.特征提取和 ...

  8. opengl导入obj模型

    在经过查阅各种资料以及各种bug之后,终于成功的实现了导入基本的obj模型. 首相介绍一下什么是obj模型 一.什么是OBJ模型 obj文件实际上是一个文本文档,主要有以下数据,一般可以通过blend ...

  9. Django:学习笔记(7)——模型进阶

    Django:学习笔记(7)——模型进阶 模型的继承 我们在面向对象的编程中,一个很重要的的版块,就是类的继承.父类保存了所有子类共有的内容,子类通过继承它来减少冗余代码并进行灵活扩展. 在Djang ...

随机推荐

  1. oracle中dual表的使用

    dual表是一个虚拟表,用来和select语句一起使用.1.查看当前用户select  user from dual2.用来调用系统函数select to_char(sysdate,'yyyy-mm- ...

  2. 前端不为人知的一面–前端冷知识集锦 原文地址(http://web.jobbole.com/83473/);

    前端已经被玩儿坏了!像console.log()可以向控制台输出图片等炫酷的玩意已经不是什么新闻了,像用||操作符给变量赋默认值也是人尽皆知的旧闻了,今天看到Quora上一个帖子,瞬间又GET了好多前 ...

  3. overflow的劲爆知识点

    1.属性 visible(默认) hidden(此处是隐藏不是裁剪) scroll(滚动条) auto(智能路线 当超出范围时则出现滚动条) inherit 不常用  存在兼容性问题 2.进入CSS3 ...

  4. laravel页面间的传值

    可以在前端页面元素上添加onclick事件  onclick='selectRaw(this)' js中写function selectRaw(obj){ var data=$(obj).attr(& ...

  5. html插入视频

    http://www.jb51.net/web/168548.html http://www.w3school.com.cn/html/html_media.asp

  6. NEON简介【转】

    转自:http://blog.csdn.net/fengbingchun/article/details/38020265 版权声明:本文为博主原创文章,未经博主允许不得转载. “ARM Advanc ...

  7. [转]JEXUS的高级配置

    转自:http://www.cnblogs.com/xiaodiejinghong/archive/2013/04/14/3019660.html 前一回合,我们对服务器软件Jexus作了简单的介绍, ...

  8. Hive与数据库的异同

    一.Hive简介 Hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供完整的sql查询功能,可以将sql语句转换为MapReduce任务进行运行.其优点是学习 ...

  9. PHP建站通过服务器架构及实战的方法

    PHP的环境搭建 PHP的帮助使用和配置文件 PHP的Hello World PHP的库函数调用 PHP的Web程序 PHP的函数和面向对象使用 PHP的数据库访问 Nginx安装和配置访问 Word ...

  10. canvas 动画

    1.随机产生形状,做360度运转,带有一个开始开始按钮一个停止按钮 var canvas=$('.mycanvas'); canvas.attr("width",500);//$( ...