#!/usr/bin/env python # coding: utf-8 # In[1]: import random import os import os.path import sys from OCC.STEPControl import STEPControl_Reader from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity # In[2]: from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer # In[3]: def read_step_file(filename): """ read the STEP file and returns a compound """ step_reader = STEPControl_Reader() status = step_reader.ReadFile(filename) if status == IFSelect_RetDone: # check status failsonly = False step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity) step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity) ok = step_reader.TransferRoot(1) _nbs = step_reader.NbShapes() aResShape = step_reader.Shape(1) else: print("Error: can't read file.") sys.exit(0) return aResShape shp = read_step_file(os.path.join('..', 'models', 'RC_Buggy_2_front_suspension.stp')) # In[4]: my_renderer = JupyterRenderer() # In[5]: my_renderer.DisplayShape(shp) # In[ ]: