From ebcc449f8454e712ffac8cd5a885dd3a7b96e7e2 Mon Sep 17 00:00:00 2001 From: Jeremy Wright Date: Thu, 9 Oct 2014 23:04:48 -0400 Subject: [PATCH] Started implementing the final form of the revolve operation. --- cadquery/CQ.py | 10 +++++++--- cadquery/freecad_impl/shapes.py | 4 ++-- examples/FreeCAD/Ex025_Revolution.py | 13 +++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/cadquery/CQ.py b/cadquery/CQ.py index 277d768..d23352e 100644 --- a/cadquery/CQ.py +++ b/cadquery/CQ.py @@ -1868,12 +1868,14 @@ class Workplane(CQ): else: return self.newObject([r]) - def revolve(self,angleDegrees,combine=True): + def revolve(self,angleDegrees=360,axisStart=None,axisEnd=None,combine=True): """ Use all un-revolved wires in the parent chain to create a solid. :param angleDegrees: the angle to revolve through. :type angleDegrees: float, anything less than 360 degrees will leave the shape open + :param axisStart: the origin of the center of rotation + :param axisEnd: a vector aligned with the the axis of rotation :param boolean combine: True to combine the resulting solid with parent solids if found. :return: a CQ object with the resulting solid selected. @@ -2127,11 +2129,13 @@ class Workplane(CQ): return Compound.makeCompound(toFuse) - def _revolve(self,angleDegrees): + def _revolve(self,angleDegrees=360,axisStart=None,axisEnd=None): """ Make a solid from the existing set of pending wires. - :param angleDegrees: the angle to revolve throug + :param angleDegrees: the angle to revolve through + :param axisStart: the origin of the center of rotation + :param axisEnd: a vector aligned with the the axis of rotation :return: a FreeCAD solid, suitable for boolean operations. This method is a utility method, primarily for plugin and internal use. diff --git a/cadquery/freecad_impl/shapes.py b/cadquery/freecad_impl/shapes.py index cf07d72..f8e633a 100644 --- a/cadquery/freecad_impl/shapes.py +++ b/cadquery/freecad_impl/shapes.py @@ -738,7 +738,7 @@ class Solid(Shape): return Shape.cast(result) @classmethod - def revolve(cls,outerWire,innerWires, angleDegrees): + def revolve(cls,outerWire,innerWires,angleDegrees): """ Attempt to revolve the list of wires into a solid in the provided direction @@ -764,7 +764,7 @@ class Solid(Shape): freeCADWires.append(w.wrapped) f = FreeCADPart.Face(freeCADWires) - result = f.revolve(FreeCAD.Base.Vector(0,0,0), FreeCAD.Base.Vector(0,1,0), angleDegrees) + result = f.revolve(FreeCAD.Base.Vector(-5,-5,0), FreeCAD.Base.Vector(0,1,0), angleDegrees) return Shape.cast(result) diff --git a/examples/FreeCAD/Ex025_Revolution.py b/examples/FreeCAD/Ex025_Revolution.py index 03815cd..880cba2 100644 --- a/examples/FreeCAD/Ex025_Revolution.py +++ b/examples/FreeCAD/Ex025_Revolution.py @@ -20,12 +20,17 @@ import cadquery import Part #The dimensions of the model. These can be modified rather than changing the shape's code directly. -rectangle_width = 15.0 -rectange_length = 15.0 +rectangle_width = 10.0 +rectange_length = 10.0 angleDegrees = 360.0 -#Extrude a cylindrical plate with a rectangular hole in the middle of it -result = cadquery.Workplane("front").rect(rectangle_width, rectange_length, False).revolve(angleDegrees) +#Revolve a cylinder from a rectangle +#Switch comments around in this section to try the revolve operation with different parameters +result = cadquery.Workplane("XY").rect(rectangle_width, rectange_length).revolve() +#result = cadquery.Workplane("XY").rect(rectangle_width, rectange_length).revolve(angleDegrees) +#result = cadquery.Workplane("XY").rect(rectangle_width, rectange_length).revolve(angleDegrees,(-5,-5,0)) +#result = cadquery.Workplane("XY").rect(rectangle_width, rectange_length).revolve(angleDegrees,(-5,-5,0),(-5,5,0)) +#result = cadquery.Workplane("XY").rect(rectangle_width, rectange_length).revolve(angleDegrees,(-5,-5,0),(-5,5,0),False) #Get a cadquery solid object solid = result.val()