if not args:
return
- assert(len(args) == 2 or len(args) == 1)
+ assert(len(args) in (1, 2))
if len(args) == 2:
self.setPoints(*args)
elif len(args) == 1:
self.setCylindricalFace(*args)
+
+ self._execute()
pass
def __clear(self):
if not args:
return
- assert(len(args) == 2 or len(args) == 4)
+ assert(len(args) in (2, 4))
if len(args) == 2:
self.setFaceAndDistance(*args)
elif len(args) == 4:
self.setGeneralEquation(*args)
+
+ self._execute()
pass
def __clear(self):
if not args:
return
+ assert(len(args) == 3)
self.setPoint(*args)
+
+ self._execute()
pass
def setPoint(self, x, y, z):
return
assert(len(args) == 1)
- self.setFilePath(*args)
+ self.setFilePath(args[0])
+
+ self._execute()
pass
def setFilePath(self, file_path):
self.setFilePath(args[0])
self.setFileFormat(args[1])
self.setObjects(args[2])
+
+ self._execute()
pass
def setFilePath(self, file_path):
class Boolean(Interface):
"""Abstract root class of Boolean Features."""
- def __init__(self, feature, main_objects, tool_objects, bool_type):
+ def __init__(self, feature, *args):
Interface.__init__(self, feature)
assert(self._feature.getKind() == "Boolean")
assert(self._tool_objects)
assert(self._bool_type)
+ if not args:
+ return
+
+ assert(len(args) == 3)
+ main_objects, tool_objects, bool_type = args
+
self.setMainObjects(main_objects)
self.setToolObjects(tool_objects)
self.setBoolType(bool_type)
+
+ self._execute()
pass
def setMainObjects(self, main_objects):
if not args:
return
- self.setBase(args[0])
-
+ assert(len(args) in (2, 3, 5))
+ base = args[0]
args = args[1:]
- assert(len(args) in (1, 2, 4))
+
+ self.setBase(base)
if len(args) == 4:
self.setPlanesAndOffsets(*args)
class ExtrusionBoolean(CompositeBoolean):
def __init__(self, feature, *args):
- CompositeBoolean.__init__(self, feature, *args)
+ CompositeBoolean.__init__(self, feature, *args[:3])
+ args = args[3:]
self._CreationMethod = self._feature.string("CreationMethod")
self._to_size = self._feature.data().real("to_size")
if not args:
return
- assert(len(args) == 4 or len(args) == 2)
+ assert(len(args) in (2, 4))
if len(args) == 4:
self.setPlanesAndOffsets(*args)
elif len(args) == 2:
self.setSizes(*args)
+
+ self._execute()
pass
def __clear(self):
class ExtrusionSketch(CompositeSketch):
def __init__(self, feature, *args):
- CompositeSketch.__init__(self, feature, *args)
+ CompositeSketch.__init__(self, feature, *args[:2])
+ args = args[2:]
self._CreationMethod = self._feature.string("CreationMethod")
self._to_size = self._feature.data().real("to_size")
if not args:
return
- assert(len(args) == 4 or len(args) == 2)
+ assert(len(args) in (2, 4))
if len(args) == 4:
self.setPlanesAndOffsets(*args)
elif len(args) == 2:
self.setSizes(*args)
+
+ self._execute()
pass
def __clear(self):
assert(self._group_list)
+ if not args:
+ return
+
assert(len(args) == 1)
self.setGroupList(args[0])
+
+ self._execute()
pass
def setGroupList(self, main_objects):
class Partition(Interface):
"""Interface on an Partition feature."""
- def __init__(self, feature, main_objects=None,
- tool_objects=None, partition_combine=None):
+ def __init__(self, feature, *args):
"""Initialize an Partition feature with given parameters.
Expected arguments:
assert(self._tool_objects)
assert(self._partition_combine)
- if main_objects is None:
+ if not args:
return
- self._fill_attribute(self._main_objects, main_objects)
- self._fill_attribute(self._tool_objects, tool_objects)
- self._fill_attribute(self._partition_combine, partition_combine)
+ assert(len(args) == 3)
+ main_objects, tool_objects, partition_combine = args
+
+ self.setMainObjects(main_objects)
+ self.setToolObjects(tool_objects)
+ self.setPartitionCombine(partition_combine)
+
+ self._execute()
pass
def setMainObjects(self, main_objects):
assert(self._reverse_direction)
assert(self._centering)
+ if not args:
+ return
+
assert(len(args) == 5)
self.setObjectList(args[0])
self.setStartShape(args[1])
self.setEndShape(args[2])
self.setReverseDirection(args[3])
self.setCentering(args[4])
+
+ self._execute()
pass
def setObjectList(self, objects_list):
class Revolution(Interface):
"""Interface on an Revolution feature."""
- def __init__(self, feature, base=None, axis_object=None, *args):
+ def __init__(self, feature, *args):
"""Initialize an Revolution feature with given parameters.
Expected arguments for all modes:
assert(self._from_object)
assert(self._from_offset)
- if base is None:
+ 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)
- )
- pass
+ self.setAngles(*args)
- def __setBase(self, base):
- self._fill_attribute(self._base, base)
- pass
-
- 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 setBase(self, base):
"""Modify base attribute of the feature.
See __init__.
"""
- self.__setBase(base)
+ self._fill_attribute(self._base, base)
pass
def setAxisObject(self, axis_object):
See __init__.
"""
- self.__setAxisObject(axis_object)
+ 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.__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.__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
class RevolutionBoolean(CompositeBoolean):
def __init__(self, feature, *args):
- CompositeBoolean.__init__(self, feature, *args)
+ CompositeBoolean.__init__(self, feature, *args[:3])
+ args = args[3:]
self._axis_object = self._feature.data().selection("axis_object")
self._CreationMethod = self._feature.string("CreationMethod")
if not args:
return
- self.setAxisObject(args[0])
+ assert(len(args) in (3, 5))
+ axis_object = args[0]
+ args = args[1:]
+
+ self.setAxisObject(axis_object)
if len(args) == 4:
- self.setPlanesAndOffsets(*args[1:])
+ self.setPlanesAndOffsets(*args)
elif len(args) == 2:
- self.setAngles(*args[1:])
+ self.setAngles(*args)
+
+ self._execute()
pass
def __clear(self):
class RevolutionSketch(CompositeSketch):
def __init__(self, feature, *args):
- CompositeSketch.__init__(self, feature, *args)
+ CompositeSketch.__init__(self, feature, *args[:2])
+ args = args[2:]
self._axis_object = self._feature.data().selection("axis_object")
self._CreationMethod = self._feature.string("CreationMethod")
if not args:
return
- self.setAxisObject(args[0])
+ assert(len(args) in (3, 5))
+ axis_object = args[0]
+ args = args[1:]
+
+ self.setAxisObject(axis_object)
if len(args) == 4:
- self.setPlanesAndOffsets(*args[1:])
+ self.setPlanesAndOffsets(*args)
elif len(args) == 2:
- self.setAngles(*args[1:])
+ self.setAngles(*args)
+
+ self._execute()
pass
def __clear(self):
-
from model.roots import Interface
self._sketch_selection = self._feature.selection("sketch_selection")
self._boolean_objects = self._feature.selectionList("boolean_objects")
+ assert(self._sketch)
+ assert(self._sketch_selection)
+ assert(self._boolean_objects)
+
if not args:
return
+ assert(len(args) == 3)
+ sketch, sketch_selection, boolean_objects = args
+
+ self.setSketch(sketch)
+ self.setSketchSelection(sketch_selection)
+ self.setBooleanObjects(boolean_objects)
+ pass
+
+ def setSketch(self, sketch):
+ self._fill_attribute(self._sketch, sketch)
+ pass
+
+ def setSketchSelection(self, sketch_selection):
+ self._fill_attribute(self._sketch_selection, sketch_selection)
+ pass
+
+ def setBooleanObjects(self, boolean_objects):
+ self._fill_attribute(self._boolean_objects, boolean_objects)
+ pass
+
+
class CompositeSketch(Interface):
def __init__(self, feature, *args):
self._sketch = self._feature.reference("sketch")
self._sketch_selection = self._feature.selection("sketch_selection")
+ assert(self._sketch)
+ assert(self._sketch_selection)
+
if not args:
return
+
+ assert(len(args) == 2)
+ sketch, sketch_selection = args
+
+ self.setSketch(sketch)
+ self.setSketchSelection(sketch_selection)
+ pass
+
+ def setSketch(self, sketch):
+ self._fill_attribute(self._sketch, sketch)
+ pass
+
+ def setSketchSelection(self, sketch_selection):
+ self._fill_attribute(self._sketch_selection, sketch_selection)
+ pass
assert(self._axis_object)
assert(self._angle)
+ if not args:
+ return
+
assert(len(args) == 3)
self.setMainObjects(args[0])
self.setAxisObject(args[1])
self.setAngle(args[2])
+
+ self._execute()
pass
def setMainObjects(self, main_objects):
assert(self._axis_object)
assert(self._distance)
+ if not args:
+ return
+
assert(len(args) == 3)
self.setMainObjects(args[0])
self.setAxisObject(args[1])
self.setDistance(args[2])
+
+ self._execute()
pass
def setMainObjects(self, main_objects):
assert(len(args) == 2)
self.setName(args[0])
self.setExpression(args[1])
+
+ self._execute()
pass
def setName(self, name):
"""Adds a new Part to the given Partset and activates the Part."""
Interface.__init__(self, feature)
assert(self._feature.getKind() == "Part")
+
+ self._execute()
pass
def document(self):
def __init__(self, feature, *args):
Interface.__init__(self, feature)
assert(self._feature.getKind() == "SketchArc")
-
+
self._center = geomDataAPI_Point2D(
self._feature.data().attribute("ArcCenter")
)
def centerData(self):
"""Return the center point data."""
return self._center
-
+
def startPointData(self):
"""Return the start point data."""
return self._start_point
-
+
def endPointData(self):
"""Return the end point data."""
return self._end_point
def result(self):
"""Return the arc circular line attribute."""
return self._feature.lastResult()
-
+
########
#
# Private methods
#
########
-
- def __createByCoordinates(self, center_x, center_y,
- start_x, start_y,
+
+ def __createByCoordinates(self, center_x, center_y,
+ start_x, start_y,
end_x, end_y):
"""Create an arc by point coordinates."""
self._center.setValue(center_x, center_y)
self._start_point.setValue(start_x, start_y)
self._end_point.setValue(end_x, end_y)
self._feature.execute()
-
+
def __createByPoints(self, center, start, end):
"""Create an arc with point objects."""
self._center.setValue(center.x(), center.y())
self._start_point.setValue(start.x(), start.y())
self._end_point.setValue(end.x(), end.y())
self._feature.execute()
-
-
-
-
-
self.__sketchOnFace(plane)
else:
self.__sketchOnPlane(plane)
+ pass
def __sketchOnPlane(self, plane):
"""Create the sketch on a plane."""