import random
import os
import os.path
import sys
from OCC.STEPControl import STEPControl_Reader
from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity
from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer
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'))
my_renderer = JupyterRenderer()
my_renderer.DisplayShape(shp)
Failed to display Jupyter Widget of type Renderer
.
If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.
If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.