class Revolution(Interface):
- """Interface on an Revolution feature."""
-
- def __init__(self, feature, base=None, axis_object=None, *args):
- """Initialize an Revolution feature with given parameters.
-
- Expected arguments for all modes:
- feature -- an Revolution feature
-
- Expected arguments for initializing the feature:
- base -- name, sketch or list of names and sketches.
- If base is None then don't change the feature.
- axis_object -- name, edge for axis
-
- For ByAngles mode (expect 2 arguments):
- to_angle -- upper angle
- from_angle -- lower angle
+ """Interface class for Revolution features.
+
+ Revolution(feature) -> feature interface without initialization
+ Revolution(feature, base, axis_object, to_angle, from_angle) ->
+ feature interface initialized from arguments:
+ - base -- name, sketch or list of names and sketches
+ - axis_object -- name, edge for axis
+ - to_angle -- upper angle
+ - from_angle -- lower angle
+ Revolution(feature, base, axis_object,
+ to_object, to_offset, from_object, from_offset) ->
+ feature interface initialized from arguments:
+ - base -- name, sketch or list of names and sketches
+ - axis_object -- name, edge for axis
+ - to_object -- upper object (plane)
+ - to_offset -- offset from upper object
+ - from_object -- lower object (plane)
+ - from_offset -- offset from lower object
+ """
- For ByPlanesAndOffsets mode (expect 4 arguments):
- to_object -- upper object (plane)
- to_offset -- offset from upper object
- from_object -- lower object (plane)
- from_offset -- offset from lower object
- """
+ def __init__(self, feature, *args):
+ """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
Interface.__init__(self, feature)
assert(self._feature.getKind() == "Revolution")
self._from_object = self._feature.data().selection("from_object")
self._from_offset = self._feature.data().real("from_offset")
- if base is None:
+ assert(self._base)
+ assert(self._axis_object)
+ assert(self._CreationMethod)
+ assert(self._to_angle)
+ assert(self._from_angle)
+ assert(self._to_object)
+ assert(self._to_offset)
+ assert(self._from_object)
+ assert(self._from_offset)
+
+ if not args:
return
- self.__setBase(base)
- self.__setAxisObject(axis_object)
+ assert(len(args) in (4, 6))
+
+ base, axis_object = args[:2]
+ args = args[2:]
+
+ self.setBase(base)
+ self.setAxisObject(axis_object)
if len(args) == 4:
- self.__createByPlanesAndOffsets(*args)
+ self.setPlanesAndOffsets(*args)
elif len(args) == 2:
- self.__createByAngles(*args)
- else:
- raise AssertionError(
- "Revolution takes 5 or 7 arguments (%s given)" %
- (len(args) + 3)
- )
-
- self.__execute()
- pass
-
- def __setBase(self, base):
- self._fill_attribute(self._base, base)
- pass
+ self.setAngles(*args)
- def __setAxisObject(self, axis_object):
- self._fill_attribute(self._axis_object, axis_object)
+ self._execute()
pass
def __clear(self):
self._fill_attribute(self._from_offset, 0)
pass
- def __createByAngles(self, to_angle, from_angle):
- self.__clear()
- self._CreationMethod.setValue("ByAngles")
- self._fill_attribute(self._to_angle, to_angle)
- self._fill_attribute(self._from_angle, from_angle)
- pass
-
- def __createByPlanesAndOffsets(self, to_object, to_offset,
- from_object, from_offset):
- self.__clear()
- self._CreationMethod.setValue("ByPlanesAndOffsets")
- self._fill_attribute(self._to_object, to_object)
- self._fill_attribute(self._to_offset, to_offset)
- self._fill_attribute(self._from_object, from_object)
- self._fill_attribute(self._from_offset, from_offset)
- pass
-
- def __execute(self):
- if self.areInputValid():
- self.execute()
- else:
- raise Exception("Cannot execute Revolution: %s" %
- self._feature.error())
-
def setBase(self, base):
"""Modify base attribute of the feature.
See __init__.
"""
- self.__setBase(base)
- self.__execute()
+ self._fill_attribute(self._base, base)
pass
def setAxisObject(self, axis_object):
See __init__.
"""
- self.__setAxisObject(axis_object)
- self.__execute()
+ self._fill_attribute(self._axis_object, axis_object)
pass
- def setAngles(self, *args):
+ def setAngles(self, to_angle, from_angle):
"""Modify the to_angle, from_angle attributes of the feature.
See __init__.
"""
- self.__createByAngles(*args)
- self.__execute()
+ self.__clear()
+ self._CreationMethod.setValue("ByAngles")
+ self._fill_attribute(self._to_angle, to_angle)
+ self._fill_attribute(self._from_angle, from_angle)
pass
- def setPlanesAndOffsets(self, *args):
+ def setPlanesAndOffsets(self, to_object, to_offset,
+ from_object, from_offset):
"""Modify planes and offsets attributes of the feature.
See __init__.
"""
- self.__createByPlanesAndOffsets(*args)
- self.__execute()
+ self.__clear()
+ self._CreationMethod.setValue("ByPlanesAndOffsets")
+ self._fill_attribute(self._to_object, to_object)
+ self._fill_attribute(self._to_offset, to_offset)
+ self._fill_attribute(self._from_object, from_object)
+ self._fill_attribute(self._from_offset, from_offset)
pass