Analyzing Step Files

I am very new to Open Cascade I am trying to import a STEP file and extract data about points on the surface and boundary curves etc. 

I am loading the files into the pythonOCC with from OCC.STEPControl import STEPControl_Reader I am then trying to use from OCC.ShapeExtend import ShapeExtend_CompositeSurface to analyze and extract data from what is imported. 

How do I pass the STEP information from the import to the function ShapeExtend_CompositeSurface everything I try throws an error and I can't find examples online. 

from OCC.STEPControl import STEPControl_Reader
from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity
from OCC.Display.SimpleGui import init_display
from OCC.ShapeExtend import ShapeExtend_CompositeSurface

extend = ShapeExtend_CompositeSurface()
step_reader = STEPControl_Reader()
status = step_reader.ReadFile('L2.stp')

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)
    print("Error: can't read file.")
display, start_display, add_menu, add_function_to_menu = init_display()
display.DisplayShape(aResShape, update=True)


Forum supervisor's picture


Why do you try to use ShapeExtend_CompositeSurface? This class has little to do with your task, as far as I understand.

If you want to extract geometrical information from an imported shape (TopoDS_Shape), you need tools to parse the shape graph (see TopoDS_Iterator and TopExp_Explorer) and tools to extract geometric object from sub-shapes (see BRep_Tool).

Actually, I’d recommend you to take our e-learning course – it would improve your understanding of the main concepts and APIs a lot.

Best regards,

Forum supervisor