Ejemplo n.º 1
0
def boolean_cut(shapeToCutFrom, cuttingShape):
    from OCCT.BRepAlgoAPI import BRepAlgoAPI_Cut
    try:
        cut = BRepAlgoAPI_Cut(shapeToCutFrom, cuttingShape)
        print("Can work?", cut.BuilderCanWork())
        _error = {0: '- Ok',
                  1: '- The Object is created but Nothing is Done',
                  2: '- Null source shapes is not allowed',
                  3: '- Check types of the arguments',
                  4: '- Can not allocate memory for the DSFiller',
                  5: '- The Builder can not work with such types of arguments',
                  6: '- Unknown operation is not allowed',
                  7: '- Can not allocate memory for the Builder',
                  }
        print("Error status:", _error[cut.ErrorStatus()])
        cut.RefineEdges()
        cut.FuseEdges()
        shp = cut.Shape()
        cut.Destroy()
        return shp
    except:
        print("Failed to boolean cut")
        return shapeToCutFrom
def center_hole(base):
    cylinder = BRepPrimAPI_MakeCylinder(center_radius, thickness).Shape()
    cut = BRepAlgoAPI_Cut(base, cylinder)
    return cut.Shape()
def boolean_cut(shapeToCutFrom, cuttingShape):
    from OCCT.BRepAlgoAPI import BRepAlgoAPI_Cut
    cut = BRepAlgoAPI_Cut(shapeToCutFrom, cuttingShape)

    shp = cut.Shape()
    return shp