def offset_cube(event=None):
    S2 = BRepPrimAPI_MakeBox(gp_Pnt(300, 0, 0), 220, 140, 180).Shape()
    offsetB = BRepOffsetAPI_MakeOffsetShape(S2, -20, 0.01, BRepOffset_Skin, False, False, GeomAbs_Arc)
    offB = display.DisplayColoredShape(S2, 'BLUE')
    display.Context.SetTransparency(offB, 0.3)
    display.DisplayColoredShape(offsetB.Shape(), 'GREEN')
    display.FitAll()
Esempio n. 2
0
def make_offset_shape(shapeToOffset,
                      offsetDistance,
                      tolerance=TOLERANCE,
                      offsetMode=BRepOffset_Skin,
                      intersection=False,
                      selfintersection=False,
                      joinType=GeomAbs_Arc):
    """
    builds an offsetted shell from a shape
    construct an offsetted version of the shape
    """
    from OCC.BRepOffsetAPI import BRepOffsetAPI_MakeOffsetShape
    try:
        offset = BRepOffsetAPI_MakeOffsetShape(shapeToOffset, offsetDistance,
                                               tolerance, offsetMode,
                                               intersection, selfintersection,
                                               joinType)
        if offset.IsDone():
            return offset.Shape()
        else:
            return None
    except RuntimeError('failed to offset shape'):
        return None
Esempio n. 3
0
    def update_shape(self, change={}):
        d = self.declaration

        #: Get the shape to apply the fillet to
        s = self.get_shape()

        if isinstance(s.shape, BRepBuilderAPI_MakeWire):
            shape = BRepOffsetAPI_MakeOffset(s.shape.Wire(),
                                             self.join_types[d.join_type])
            shape.Perform(d.offset)
            self.shape = shape
        else:

            self.shape = BRepOffsetAPI_MakeOffsetShape(
                s.shape.Shape() if hasattr(s.shape, 'Shape') else s.shape,
                d.offset, d.tolerance, self.offset_modes[d.offset_mode],
                d.intersection, False, self.join_types[d.join_type])
Esempio n. 4
0
def offSetShell(shape):
    b = BRepOffsetAPI_MakeOffsetShape(solid, -0.15, 0, False, False)
    b.Build()
    return b.Shape()