pythonOCC comes with importers/exporters for the most commonly used standard data files format in engineering: STEP (AP203 and AP214), 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. The following screenshots show the import of the STEP file describing the i6400r ABB robot (courtesy of the ABB, STEP file downloaded from the ABB Library).
STEP file import (6.1Mb, 75895 entities)

How do you import STEP in PythonOCC. What command to use?
I’m kinda total neewbie to python and pythonOCC. But I have managed to install and run it, and show one box in it.
I need to import STEP214. Does PythonOCC take color information from STEP214?
Regards
Petar
The Open Cascade Application Framework (OCAF), available under pythonocc, support colors for the STEP Application Protocol 214.
Thomas,
Thank you for your response. Do you have any tutorial about how it is done?
Regards
Petar Perisin
Have a look at the StepOCAF_Export class, from the Utils.DataExchange package.
Can you provide a sample AP214 Part 21 file including colors and/or layers in order to develop an example (it’s not available from the examples/Level2/examples folder).
Hi,
You can try this example (or another one from this site)
http://www.3dcontentcentral.com/parts/download-part.aspx?id=13105&catalogid=171
Just register and download file in STEP format (AP214). I’ll take a look at that class, but I would still like to see a video tutorial on how to import STEP in PythonOCC, because I’m quite new to python and pythonOCC.
Regards,
Petar Perisin
Hi.
I saw the package you were talking about, but it has only ability to export STEP 214. I don’t see StepOCAF_Import class.
Is it possible to import STEP AP214 (does regular STEP import class imports AP214)?
Regards
Petar Perisin
In the à.4 release, the STEP_Importer class can handle any of Part21 STEP files generated from AP203, AP214 and AP209.
The STEP_Exporter only exports to AP214 (which is the OCC default STEP AP). In the next pythonOCC release, it will be possible to change the default AP (between AP203 and AP214).
Hi,
I have been playing with this STEP export. I have also found pythonocc-examples project on code.google.com (you should also include this google code project on your web site, because there is no link to it here – I have found the link on google). Over here there is test_XDE.py and the program creates some moduels, colors them and exports STEP with colors. Couple of questions:
1. Over there there StepOCAF_Export class (from the Utils.DataExchange package) is not used. It Uses STEPCAFControl writer. Is this the same thing (it confuses me a little bit) or am I wrong?
2. I know that you were talking about how StepOCAF supports layers and colors. This layers is what I’m interested in. Are this accually ‘Parts’ that appear after I import Step file into another program, so I can see that Step is accually made from many parts (XDE_test.step has three parts – 2 boxes and a cylinder)?
3. Code does not seem to work untill you comment lines from 69-79 (and, of course, uncomment lines 83-86). He reports error on line 74 – “Attribute Error: ‘TColStd_ListIteratorOfListOfInteger’ object has no attribute ‘Value’ “. It is probably connected to line 72, where this is assigned. How to fix this (in other way than comment lines from 69 to 79)
4. I have been looking through the code (newbie look) and I have figured where new document is created, where shapes are created, where components are referenced in assembly and coloured after that. But, as hard as I try I can not figure out what do lines 69-79 do? What do they do?
5. Is there a way to assign colors based on Red-Green-Blue values (this was not used here) and if yes, what is the range for this values (is it 0-1 float values like in FreeCAD or is it 0-256 integer values) – can you give me an example of this?
Thank you very much for pythonOCC
Regards
Petar Perisin
Hi,
I wanted to explain what am I doing. I’m trying to export complex shapes from FreeCAD to STEP with colors using pythonOCC. So far I have managed to do that with simple shapes like sphere, box, cone ect. But how to export cut between sphere and a box. I saw another example test_cut.py, and from there I took and modified a few things:
from OCC import BRepPrimAPI, BRepBuilderAPI, gp, Geom, STEPControl,\
BRepAlgoAPI
R = 20.
sphere = BRepPrimAPI.BRepPrimAPI_MakeSphere(R)
box = BRepPrimAPI.BRepPrimAPI_MakeBox(100,100,100)
cut = BRepAlgoAPI.BRepAlgoAPI_Cut(box.Shape(), sphere.Shape())
now, how to export ‘cut’ as STEP with color. He reports some error that ‘cut’ is of different type. How to make ‘cut’ be good type?
@petar: use the .Shape() method of the BRepAlgoAPI_Cut class in order to get a TopoDS_Shape that can be passed to the STEPExporter:
cut_shape = cut.Shape()
Ok, Thank you for your response. I did manage to insert this cut_shape instead of box in test_XDE.py (program that exports colored STEP)
But it turns out that this program exports only simple shapes (box, sphere, cylinder, cone) with color. You can not export cut with color, right?
P.S. test_XDE.py has on line 74:
v = iterTagList.Value()
should this be:
v = iterTagList.GetValue()
because there is no ‘Value’ parameter