Started implementing the final form of the revolve operation.

This commit is contained in:
Jeremy Wright 2014-10-09 23:04:48 -04:00
parent f20d52ebd9
commit ebcc449f84
3 changed files with 18 additions and 9 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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()