コード例 #1
0
ファイル: shapes.py プロジェクト: fragmuffin/cadquery
    def revolve(cls, outerWire, innerWires, angleDegrees, axisStart, axisEnd):
        """
        Attempt to revolve the list of wires into a solid in the provided direction

        :param outerWire: the outermost wire
        :param innerWires: a list of inner wires
        :param angleDegrees: the angle to revolve through.
        :type angleDegrees: float, anything less than 360 degrees will leave the shape open
        :param axisStart: the start point of the axis of rotation
        :type axisStart: tuple, a two tuple
        :param axisEnd: the end point of the axis of rotation
        :type axisEnd: tuple, a two tuple
        :return: a Solid object

        The wires must not intersect

        * all wires must be closed
        * there cannot be any intersecting or self-intersecting wires
        * wires must be listed from outside in
        * more than one levels of nesting is not supported reliably
        * the wire(s) that you're revolving cannot be centered

        This method will attempt to sort the wires, but there is much work remaining to make this method
        reliable.
        """
        face = Face.makeFromWires(outerWire, innerWires)

        v1 = Vector(axisStart)
        v2 = Vector(axisEnd)
        v2 = v2 - v1
        revol_builder = BRepPrimAPI_MakeRevol(face.wrapped,
                                              gp_Ax1(v1.toPnt(), v2.toDir()),
                                              angleDegrees * DEG2RAD, True)

        return cls(revol_builder.Shape())
コード例 #2
0
ファイル: shapes.py プロジェクト: fragmuffin/cadquery
    def makePlane(cls, length, width, basePnt=(0, 0, 0), dir=(0, 0, 1)):
        basePnt = Vector(basePnt)
        dir = Vector(dir)

        pln_geom = gp_Pln(basePnt.toPnt(), dir.toDir())

        return cls(
            BRepBuilderAPI_MakeFace(pln_geom, -width * 0.5, width * 0.5,
                                    -length * 0.5, length * 0.5).Face())
コード例 #3
0
ファイル: shapes.py プロジェクト: fragmuffin/cadquery
    def makeCircle(cls,
                   radius,
                   pnt=Vector(0, 0, 0),
                   dir=Vector(0, 0, 1),
                   angle1=360.0,
                   angle2=360):
        """

        """
        pnt = Vector(pnt)
        dir = Vector(dir)

        circle_gp = gp_Circ(gp_Ax2(pnt.toPnt(), dir.toDir()), radius)

        if angle1 == angle2:  # full circle case
            return cls(BRepBuilderAPI_MakeEdge(circle_gp).Edge())
        else:  # arc case
            circle_geom = GC_MakeArcOfCircle(circle_gp, angle1 * DEG2RAD,
                                             angle2 * DEG2RAD, True).Value()
            return cls(BRepBuilderAPI_MakeEdge(circle_geom).Edge())
コード例 #4
0
ファイル: shapes.py プロジェクト: fragmuffin/cadquery
    def rotate(self, startVector, endVector, angleDegrees):
        """
        Rotates a shape around an axis
        :param startVector: start point of rotation axis  either a 3-tuple or a Vector
        :param endVector:  end point of rotation axis, either a 3-tuple or a Vector
        :param angleDegrees:  angle to rotate, in degrees
        :return: a copy of the shape, rotated
        """
        if type(startVector) == tuple:
            startVector = Vector(startVector)

        if type(endVector) == tuple:
            endVector = Vector(endVector)

        T = gp_Trsf()
        T.SetRotation(
            gp_Ax1(startVector.toPnt(), (endVector - startVector).toDir()),
            angleDegrees)

        return self._apply_transform(T)