From 512554fdf44edb7fbf6e711b221d9844d975ef36 Mon Sep 17 00:00:00 2001 From: spo Date: Tue, 27 Oct 2015 15:25:48 +0300 Subject: [PATCH] Add partition feature without tests. --- src/PythonAPI/model/features/__init__.py | 3 +- src/PythonAPI/model/features/partition.py | 83 +++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/PythonAPI/model/features/partition.py diff --git a/src/PythonAPI/model/features/__init__.py b/src/PythonAPI/model/features/__init__.py index cbc6d4fa2..763938ccc 100644 --- a/src/PythonAPI/model/features/__init__.py +++ b/src/PythonAPI/model/features/__init__.py @@ -6,4 +6,5 @@ from boolean import Subtraction as addSubtraction from boolean import Intersection as addIntersection from extrusion import addExtrusion -from revolution import addRevolution \ No newline at end of file +from revolution import addRevolution +from partition import addPartition diff --git a/src/PythonAPI/model/features/partition.py b/src/PythonAPI/model/features/partition.py new file mode 100644 index 000000000..d7226537a --- /dev/null +++ b/src/PythonAPI/model/features/partition.py @@ -0,0 +1,83 @@ +"""Partition Interface +Author: Sergey Pokhodenko +Copyright (C) 2014-20xx CEA/DEN, EDF R&D +""" + +from model.roots import Interface + + +def addPartition(part, *args): + """Add an Partition feature to the Part and return Partition. + + Pass all args to Partition __init__ function. + """ + assert(len(args) > 0 and args[0] is not None) + feature = part.addFeature("Partition") + return Partition(feature, *args) + + +class Partition(Interface): + """Interface on an Partition feature.""" + + def __init__(self, feature, main_objects=None, + tool_objects=None, partition_combine=None): + """Initialize an Partition feature with given parameters. + + Expected arguments: + feature -- an Partition feature + + Expected arguments for initializing the feature: + main_objects -- list of solids. + tool_objects -- list of solids. + partition_combine -- boolean value. + """ + Interface.__init__(self, feature) + assert(self._feature.getKind() == "Partition") + + self._main_objects = self._feature.data().selectionList("main_objects") + self._tool_objects = self._feature.data().selectionList("tool_objects") + self._partition_combine = self._feature.data().boolean("partition_combine") + + if main_objects is None: + 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) + + self.__execute() + pass + + def __execute(self): + if self.areInputValid(): + self.execute() + else: + raise Exception("Cannot execute Partition: %s" % + self._feature.error()) + + def setMainObjects(self, main_objects): + """Modify base attribute of the feature. + + See __init__. + """ + self._fill_attribute(self._main_objects, main_objects) + self.__execute() + pass + + def setToolObjects(self, tool_objects): + """Modify the to_size, from_size attributes of the feature. + + See __init__. + """ + self._fill_attribute(self._tool_objects, tool_objects) + self.__execute() + pass + + def setPartitionCombine(self, partition_combine): + """Modify planes and offsets attributes of the feature. + + See __init__. + """ + self._fill_attribute(self._partition_combine, partition_combine) + self.__execute() + pass -- 2.39.2