From 4a9131b8480996eaeb535160a7b878eef2995e55 Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 29 Oct 2015 17:27:48 +0300 Subject: [PATCH] Add assertions to set attribute for features. --- src/PythonAPI/model/construction/axis.py | 5 +++++ src/PythonAPI/model/construction/plane.py | 8 ++++++++ src/PythonAPI/model/construction/point.py | 4 ++++ src/PythonAPI/model/exchange/exchange.py | 6 ++++++ src/PythonAPI/model/features/extrusion_boolean.py | 8 ++++++++ src/PythonAPI/model/features/extrusion_sketch.py | 8 ++++++++ src/PythonAPI/model/features/group.py | 2 ++ src/PythonAPI/model/features/partition.py | 4 ++++ src/PythonAPI/model/features/placement.py | 6 ++++++ src/PythonAPI/model/features/revolution.py | 10 ++++++++++ src/PythonAPI/model/features/revolution_boolean.py | 9 +++++++++ src/PythonAPI/model/features/revolution_sketch.py | 9 +++++++++ src/PythonAPI/model/features/rotation.py | 4 ++++ src/PythonAPI/model/features/translation.py | 4 ++++ src/PythonAPI/model/parameter/parameter.py | 4 +++- 15 files changed, 90 insertions(+), 1 deletion(-) diff --git a/src/PythonAPI/model/construction/axis.py b/src/PythonAPI/model/construction/axis.py index 498ca567a..6bbaea87f 100644 --- a/src/PythonAPI/model/construction/axis.py +++ b/src/PythonAPI/model/construction/axis.py @@ -39,6 +39,11 @@ class Axis(Interface): self._SecondPoint = self._feature.data().selection("SecondPoint") self._CylindricalFace = self._feature.data().selection("CylindricalFace") + assert(self._CreationMethod) + assert(self._FirstPoint) + assert(self._SecondPoint) + assert(self._CylindricalFace) + if not args: return diff --git a/src/PythonAPI/model/construction/plane.py b/src/PythonAPI/model/construction/plane.py index caacbf654..f98c57b3e 100644 --- a/src/PythonAPI/model/construction/plane.py +++ b/src/PythonAPI/model/construction/plane.py @@ -42,6 +42,14 @@ class Plane(Interface): self._c = self._feature.data().real("C") self._d = self._feature.data().real("D") + assert(self._CreationMethod) + assert(self._plane_face) + assert(self._distance) + assert(self._a) + assert(self._b) + assert(self._c) + assert(self._d) + if not args: return diff --git a/src/PythonAPI/model/construction/point.py b/src/PythonAPI/model/construction/point.py index ad7ef42b6..c3c649784 100644 --- a/src/PythonAPI/model/construction/point.py +++ b/src/PythonAPI/model/construction/point.py @@ -34,6 +34,10 @@ class Point(Interface): self._y = self._feature.data().real("y") self._z = self._feature.data().real("z") + assert(self._x) + assert(self._y) + assert(self._z) + if not args: return diff --git a/src/PythonAPI/model/exchange/exchange.py b/src/PythonAPI/model/exchange/exchange.py index 9648b7d52..fdeaa4cca 100644 --- a/src/PythonAPI/model/exchange/exchange.py +++ b/src/PythonAPI/model/exchange/exchange.py @@ -32,6 +32,8 @@ class Import(Interface): self._file_path = self._feature.data().string("file_path") + assert(self._file_path) + if not args: return @@ -78,6 +80,10 @@ class Export(Interface): self._file_format = self._feature.data().string("file_format") self._objects = self._feature.data().selectionList("selection_list") + assert(self._file_path) + assert(self._file_format) + assert(self._objects) + if not args: return diff --git a/src/PythonAPI/model/features/extrusion_boolean.py b/src/PythonAPI/model/features/extrusion_boolean.py index 61f40a72a..a5b3f8804 100644 --- a/src/PythonAPI/model/features/extrusion_boolean.py +++ b/src/PythonAPI/model/features/extrusion_boolean.py @@ -38,6 +38,14 @@ class ExtrusionBoolean(CompositeBoolean): self._from_object = self._feature.data().selection("from_object") self._from_offset = self._feature.data().real("from_offset") + assert(self._CreationMethod) + assert(self._to_size) + assert(self._from_size) + assert(self._to_object) + assert(self._to_offset) + assert(self._from_object) + assert(self._from_offset) + if not args: return diff --git a/src/PythonAPI/model/features/extrusion_sketch.py b/src/PythonAPI/model/features/extrusion_sketch.py index fea6ff974..dd161f367 100644 --- a/src/PythonAPI/model/features/extrusion_sketch.py +++ b/src/PythonAPI/model/features/extrusion_sketch.py @@ -29,6 +29,14 @@ class ExtrusionSketch(CompositeSketch): self._from_object = self._feature.data().selection("from_object") self._from_offset = self._feature.data().real("from_offset") + assert(self._CreationMethod) + assert(self._to_size) + assert(self._from_size) + assert(self._to_object) + assert(self._to_offset) + assert(self._from_object) + assert(self._from_offset) + if not args: return diff --git a/src/PythonAPI/model/features/group.py b/src/PythonAPI/model/features/group.py index 19a795b00..a9fbfbe76 100644 --- a/src/PythonAPI/model/features/group.py +++ b/src/PythonAPI/model/features/group.py @@ -24,6 +24,8 @@ class Group(Interface): self._group_list = self._feature.data().selectionList("group_list") + assert(self._group_list) + assert(len(args) == 1) self.setGroupList(args[0]) pass diff --git a/src/PythonAPI/model/features/partition.py b/src/PythonAPI/model/features/partition.py index d7226537a..b37ef8ecd 100644 --- a/src/PythonAPI/model/features/partition.py +++ b/src/PythonAPI/model/features/partition.py @@ -38,6 +38,10 @@ class Partition(Interface): self._tool_objects = self._feature.data().selectionList("tool_objects") self._partition_combine = self._feature.data().boolean("partition_combine") + assert(self._main_objects) + assert(self._tool_objects) + assert(self._partition_combine) + if main_objects is None: return diff --git a/src/PythonAPI/model/features/placement.py b/src/PythonAPI/model/features/placement.py index 6122b83e5..78f2bf9ec 100644 --- a/src/PythonAPI/model/features/placement.py +++ b/src/PythonAPI/model/features/placement.py @@ -28,6 +28,12 @@ class Placement(Interface): self._reverse_direction = self._feature.data().boolean("placement_reverse_direction") self._centering = self._feature.data().boolean("placement_centering") + assert(self._objects_list) + assert(self._start_shape) + assert(self._end_shape) + assert(self._reverse_direction) + assert(self._centering) + assert(len(args) == 5) self.setObjectList(args[0]) self.setStartShape(args[1]) diff --git a/src/PythonAPI/model/features/revolution.py b/src/PythonAPI/model/features/revolution.py index cd43c9106..02ff46738 100644 --- a/src/PythonAPI/model/features/revolution.py +++ b/src/PythonAPI/model/features/revolution.py @@ -53,6 +53,16 @@ class Revolution(Interface): self._from_object = self._feature.data().selection("from_object") self._from_offset = self._feature.data().real("from_offset") + 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 base is None: return diff --git a/src/PythonAPI/model/features/revolution_boolean.py b/src/PythonAPI/model/features/revolution_boolean.py index 4f50c4941..3dd8ef7df 100644 --- a/src/PythonAPI/model/features/revolution_boolean.py +++ b/src/PythonAPI/model/features/revolution_boolean.py @@ -39,6 +39,15 @@ class RevolutionBoolean(CompositeBoolean): self._from_object = self._feature.data().selection("from_object") self._from_offset = self._feature.data().real("from_offset") + 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 diff --git a/src/PythonAPI/model/features/revolution_sketch.py b/src/PythonAPI/model/features/revolution_sketch.py index 5f27690a9..95de94dd3 100644 --- a/src/PythonAPI/model/features/revolution_sketch.py +++ b/src/PythonAPI/model/features/revolution_sketch.py @@ -30,6 +30,15 @@ class RevolutionSketch(CompositeSketch): self._from_object = self._feature.data().selection("from_object") self._from_offset = self._feature.data().real("from_offset") + 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 diff --git a/src/PythonAPI/model/features/rotation.py b/src/PythonAPI/model/features/rotation.py index 9df8c311d..bbec2c31e 100644 --- a/src/PythonAPI/model/features/rotation.py +++ b/src/PythonAPI/model/features/rotation.py @@ -26,6 +26,10 @@ class Rotation(Interface): self._axis_object = self._feature.data().selection("axis_object") self._angle = self._feature.data().real("angle") + assert(self._main_objects) + assert(self._axis_object) + assert(self._angle) + assert(len(args) == 3) self.setMainObjects(args[0]) self.setAxisObject(args[1]) diff --git a/src/PythonAPI/model/features/translation.py b/src/PythonAPI/model/features/translation.py index d36a72239..0260c643d 100644 --- a/src/PythonAPI/model/features/translation.py +++ b/src/PythonAPI/model/features/translation.py @@ -26,6 +26,10 @@ class Translation(Interface): self._axis_object = self._feature.data().selection("axis_object") self._distance = self._feature.data().real("distance") + assert(self._main_objects) + assert(self._axis_object) + assert(self._distance) + assert(len(args) == 3) self.setMainObjects(args[0]) self.setAxisObject(args[1]) diff --git a/src/PythonAPI/model/parameter/parameter.py b/src/PythonAPI/model/parameter/parameter.py index 7a5c28f67..377992d7c 100644 --- a/src/PythonAPI/model/parameter/parameter.py +++ b/src/PythonAPI/model/parameter/parameter.py @@ -31,10 +31,12 @@ class Parameter(Interface): Interface.__init__(self, feature) assert(self._feature.getKind() == "Parameter") - self._CreationMethod = self._feature.data().string("CreationMethod") self._variable = self._feature.data().selection("variable") self._expression = self._feature.data().real("expression") + assert(self._variable) + assert(self._expression) + if not args: return -- 2.39.2