From c2cd3b922d441d6ececf28d17a16b3310a9a4d2d Mon Sep 17 00:00:00 2001 From: spo Date: Fri, 30 Oct 2015 15:28:44 +0300 Subject: [PATCH] Improve sketcher.line feature. --- src/PythonAPI/model/sketcher/line.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/PythonAPI/model/sketcher/line.py b/src/PythonAPI/model/sketcher/line.py index 6d53e0b9f..2c2113244 100644 --- a/src/PythonAPI/model/sketcher/line.py +++ b/src/PythonAPI/model/sketcher/line.py @@ -15,6 +15,15 @@ class Line(Interface): self._end_point = geomDataAPI_Point2D( self._feature.data().attribute("EndPoint") ) + + assert(self._start_point) + assert(self._end_point) + + if not args: + return + + assert(len(args) in (1, 2, 4)) + # Set attribute values and execute if len(args) == 4: self.__createByCoordinates(*args) @@ -22,24 +31,23 @@ class Line(Interface): self.__createByPoints(*args) elif len(args) == 1: self.__createByName(*args) - else: - raise WrongNumberOfArguments( - "Arc takes 1, 2 or 4 arguments (%s given)" % len(args) - ) + + self._execute() + pass def __createByCoordinates(self, x1, y1, x2, y2): self._start_point.setValue(x1, y1) self._end_point.setValue(x2, y2) - self._feature.execute() + pass def __createByPoints(self, p1, p2): self._start_point.setValue(p1.x(), p1.y()) self._end_point.setValue(p2.x(), p2.y()) - self._feature.execute() + pass def __createByName(self, name): self._feature.data().selection("External").selectSubShape("EDGE", name) - self._feature.execute() + pass def startPointData(self): return self._start_point @@ -48,4 +56,4 @@ class Line(Interface): return self._end_point def result(self): - return self._feature.firstResult() \ No newline at end of file + return self._feature.firstResult() -- 2.39.2