from OCC.Core.STEPControl import STEPControl_Reader
from OCC.Core.StlAPI import StlAPI_Writer
input_file = 'myshape.stp' # input STEP (AP203/AP214 file)
output_file = 'myshape.stl' # output X3D file
step_reader = STEPControl_Reader()
step_reader.ReadFile( input_file )
step_reader.TransferRoot()
myshape = step_reader.Shape()
print("File readed")
# Export to STL
stl_writer = StlAPI_Writer()
stl_writer.SetASCIIMode(True)
stl_writer.Write(myshape, output_file)
print("Written")