"""This stops linters from crying.""" from math import pi from OCC.TopAbs import TopAbs_ON from OCC.TopLoc import TopLoc_Location from OCC.gp import gp_Ax1, gp_Pnt, gp_Dir, gp_Trsf from OCC.AIS import AIS_Shape from OCC.STEPControl import STEPControl_Reader from OCC.Display.SimpleGui import init_display path = 'step_test_rotor/Beispiel_214.STEP' step_reader = STEPControl_Reader() step_status = step_reader.ReadFile(path) step_reader.TransferRoot() step_shape = step_reader.Shape() display, start_display, add_menu, add_function_to_menu = init_display() display.SetSelectionMode(TopAbs_ON) step_ais_shape_handle = display.DisplayShape(step_shape, update=True) step_ais_shape = step_ais_shape_handle.GetObject() #step_ais_shape.AcceptShapeDecomposition = (lambda: True) def rotate(shp, *kwargs): print shp # list of TopoDS_Shape print kwargs # click coordinates on 2D screen as touple if shp == []: return aiShape = AIS_Shape(shp[0]) # TopoDS_Shape -> AIS_Shape aiShape.AcceptShapeDecomposition = (lambda: True) aisHandle = aiShape.GetHandle() # AIS_Shape -> Handle point = gp_Pnt(0., 0., 0.) direction = gp_Dir(0., 1., 0.) ax1 = gp_Ax1(point, direction) #aisHandle = step_ais_shape_handle # TODO debug, this works! transform = gp_Trsf() angle = 0.0 n_rotations = 200 for i in range(n_rotations): transform.SetRotation(ax1, angle) location = TopLoc_Location(transform) display.Context.SetLocation(aisHandle, location) display.Context.UpdateCurrentViewer() angle += 2*pi / n_rotations display.register_select_callback(rotate) start_display()