Salome HOME
Merge branch 'python_parametric_api' of https://git.salome-platform.org/git/modules...
[modules/shaper.git] / src / PythonAPI / model / sketcher / sketch.py
index 636ccd5dbb2ad0aadefea098e294fa7be89bcb2b..0090b269caa4e6edb045c2332ca66ff06041b777 100644 (file)
@@ -1,5 +1,6 @@
 """Sketch Feature Interface
 Author: Daniel Brunier-Coulin with contribution by Mikhail Ponikarov
+        finalized by Renaud Nedelec and Sergey Pokhodenko
 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 """
 
@@ -54,17 +55,14 @@ class Sketch(Interface):
         assert(self._norm)
         assert(self._external)
 
-        if not args:
-            return
-
-        plane = args[0]
-
-        #   self.resultype ="Face" # Type of Sketch result
-        if isinstance(plane, str):
-            self.__sketchOnFace(plane)
-        else:
-            self.__sketchOnPlane(plane)
-        pass
+        # If no arguments are given the attributes of the feature 
+        # are not Initialized
+        if args is not None:
+            plane = args[0]
+            if isinstance(plane, str):
+                self.__sketchOnFace(plane)
+            else:
+                self.__sketchOnPlane(plane)
 
     def __sketchOnPlane(self, plane):
         """Create the sketch on a plane."""
@@ -126,7 +124,7 @@ class Sketch(Interface):
         constraint = self._feature.addFeature("SketchConstraintCoincidence")
         constraint.data().refattr("ConstraintEntityA").setAttr(p1)
         constraint.data().refattr("ConstraintEntityB").setAttr(p2)
-        self._execute()
+        self.execute()
         return constraint
 
     def setParallel(self, l1, l2):
@@ -136,7 +134,7 @@ class Sketch(Interface):
         constraint = self._feature.addFeature("SketchConstraintParallel")
         constraint.data().refattr("ConstraintEntityA").setObject(l1)
         constraint.data().refattr("ConstraintEntityB").setObject(l2)
-        self._execute()
+        self.execute()
         return constraint
 
     def setPerpendicular(self, l1, l2):
@@ -146,7 +144,7 @@ class Sketch(Interface):
         constraint = self._feature.addFeature("SketchConstraintPerpendicular")
         constraint.data().refattr("ConstraintEntityA").setObject(l1)
         constraint.data().refattr("ConstraintEntityB").setObject(l2)
-        self._execute()
+        self.execute()
         return constraint
 
     def setHorizontal(self, line):
@@ -154,7 +152,7 @@ class Sketch(Interface):
         constraint to this Sketch."""
         constraint = self._feature.addFeature("SketchConstraintHorizontal")
         constraint.data().refattr("ConstraintEntityA").setObject(line)
-        self._execute()
+        self.execute()
         return constraint
 
     def setVertical(self, line):
@@ -162,7 +160,7 @@ class Sketch(Interface):
         constraint to this Sketch."""
         constraint = self._feature.addFeature("SketchConstraintVertical")
         constraint.data().refattr("ConstraintEntityA").setObject(line)
-        self._execute()
+        self.execute()
         return constraint
 
     def setDistance(self, point, line, length):
@@ -178,7 +176,7 @@ class Sketch(Interface):
         constraint.data().refattr("ConstraintEntityA").setAttr(point)
         constraint.data().refattr("ConstraintEntityB").setObject(line)
         constraint.data().real("ConstraintValue").setValue(length)
-        self._execute()
+        self.execute()
         return constraint
 
     def setLength(self, line, length):
@@ -188,7 +186,7 @@ class Sketch(Interface):
         constraint = self._feature.addFeature("SketchConstraintLength")
         constraint.data().refattr("ConstraintEntityA").setObject(line)
         constraint.data().real("ConstraintValue").setValue(length)
-        self._execute()
+        self.execute()
         return constraint
 
     def setRadius(self, circle, radius):
@@ -197,7 +195,7 @@ class Sketch(Interface):
         constraint = self._feature.addFeature("SketchConstraintRadius")
         constraint.data().refattr("ConstraintEntityA").setObject(circle)
         constraint.data().real("ConstraintValue").setValue(radius)
-        self._execute()
+        self.execute()
         return constraint
 
     def setEqual(self, object_1, object_2):
@@ -207,7 +205,7 @@ class Sketch(Interface):
         constraint = self._feature.addFeature("SketchConstraintEqual")
         constraint.data().refattr("ConstraintEntityA").setObject(object_1)
         constraint.data().refattr("ConstraintEntityB").setObject(object_2)
-        self._execute()
+        self.execute()
         return constraint
 
     def setAngle(self, line_1, line_2, angle):
@@ -217,7 +215,7 @@ class Sketch(Interface):
         constraint.data().refattr("ConstraintEntityA").setObject(line_1)
         constraint.data().refattr("ConstraintEntityB").setObject(line_2)
         constraint.data().real("ConstraintValue").setValue(angle)
-        self._execute()
+        self.execute()
         return constraint
 
     def setTangent(self, object_1, object_2):
@@ -226,7 +224,7 @@ class Sketch(Interface):
         constraint = self._feature.addFeature("SketchConstraintTangent")
         constraint.data().refattr("ConstraintEntityA").setObject(object_1)
         constraint.data().refattr("ConstraintEntityB").setObject(object_2)
-        self._execute()
+        self.execute()
         return constraint
 
     def setFillet(self, line_1, line_2, radius):
@@ -236,7 +234,7 @@ class Sketch(Interface):
         constraint.data().refattr("ConstraintEntityA").setObject(line_1)
         constraint.data().refattr("ConstraintEntityB").setObject(line_2)
         constraint.data().real("ConstraintValue").setValue(radius)
-        self._execute()
+        self.execute()
         return constraint
 
     #-------------------------------------------------------------