Beispiel #1
0
def load_stp(filename):
    """ Load a stp model """
    reader = STEPControl_Reader()
    status = reader.ReadFile(filename)
    if status != IFSelect_RetDone:
        raise ValueError("Failed to load: {}".format(filename))
    reader.PrintCheckLoad(False, IFSelect_ItemsByEntity)
    reader.PrintCheckTransfer(False, IFSelect_ItemsByEntity)
    ok = reader.TransferRoot()
    return [TopoShape(shape=reader.Shape(1))]
Beispiel #2
0
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)
        step_reader.TransferRoot(1)
        a_shape = step_reader.Shape(1)
    else:
        print("Error: can't read file.")
        sys.exit(0)
    return a_shape