Salome HOME
[PythonAPI] derived sketcher interfaces from Interface base class
[modules/shaper.git] / src / PythonAPI / model / sketcher / line.py
index 22c322f2c986b0520f85cf7f4e861835fd0fdc44..e4b0652f84c24a18fad31eaac446b06d2c8977f4 100644 (file)
@@ -1,15 +1,21 @@
 from GeomDataAPI import geomDataAPI_Point2D
+from model.roots import Interface
+from model.errors import WrongNumberOfArguments
 
-class Line():
+class Line(Interface):
     """Interface for editing of a sketch line feature."""
-    def __init__(self, line_feature, *args):
-        self._feature = line_feature
+    def __init__(self, feature, *args):
+        Interface.__init__(self, feature)
+        assert(self._feature.getKind() == "SketchLine")
+        
+        # Initialize attributes
         self._start_point = geomDataAPI_Point2D(
             self._feature.data().attribute("StartPoint")
             )
         self._end_point = geomDataAPI_Point2D(
             self._feature.data().attribute("EndPoint")
             )
+        # Set attribute values and execute
         if len(args) == 4:
             self.__createByCoordinates(*args)
         elif len(args) == 2:
@@ -17,7 +23,9 @@ class Line():
         elif len(args) == 1:
             self.__createByName(*args)
         else:
-            raise Exception("cannot create the Line")
+            raise WrongNumberOfArguments(
+                "Arc takes 1, 2 or 4 arguments (%s given)" % len(args)
+                )
 
     def __createByCoordinates(self, x1, y1, x2, y2):
         self._start_point.setValue(x1, y1)