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. 关于ScrollView中嵌套listview焦点滑动问题 解决

    (第三种,第四种简单推荐使用) 在这里我要提出的是,listview能滚动的前提是:当listview本身的高度小于listview里的子view. 第一种方法 只需在MainActivity中 找到 ...

  2. 如何在WPF应用程序中使用视频处理控件TVideoGrabber

    要在WPF 中使用 TVideoGrabber 组件,需要像下面的方法来使用 VS.NET(DLL) 版本的组件: ——复制TVideoGrabber_x.x.x.x_x86.dll到c:/windo ...

  3. phabricator

    (1)安装./bitnami-phabricator-20160523-0-linux-x64-installer.run (2)中文phabricator-zh_CN.tar解压缩到/opt/pha ...

  4. Python File.readlines() 方法

    python3的用法:

  5. composer未升级报错

    错误: Cannot adopt OID in SQUID-MIB: cacheClients ::= { cacheProtoAggregateStats 15 } Cannot adopt OID ...

  6. blade模版之页面的嵌套

    blade模版 相关关键词:@section @yield @extends @extends @show @parent(追加内容而不是覆盖) 父页面view\layout\f.blade.php ...

  7. Python 的命令行参数处理 optparse->argparse

    optaprse自2.7版开始弃用:弃用optparse模块,不会进一步开发,将继续开发argparse模块作为替代. 但是用习惯了optparse,还是很好用的撒. optparse使用起来,相比旧 ...

  8. jstl简介

    JavaServer Page Standard Tag Library是一个有用的JSP标签的集合,它封装了许多JSP应用程序通用的核心功能. JSTL支持常见的,结构性任务,如迭代和条件,标签为操 ...

  9. PHP中Array关于数组的用法

    使用函数array_keys(),得到数组中所有的键,参数:数组 $arr=array();$arr['one']="one";$arr['two']="two" ...

  10. svn搭建以及可能遇到的问题解决方案

    Svn服务器的安装和配置 1.安装svn服务器端软件从镜像服务器或者YUM源下载安装SVN服务器软件:yum install subversion mkdir /usr/local/svn //创建S ...