Salome HOME
Improve PythonAPI documentation
[modules/shaper.git] / src / PythonAPI / model / construction / axis.py
index 6bbaea87fcecf5577437fdccd01a172556aca822..ee92f4a37eeff7ab8e6f856f70459d103e72951f 100644 (file)
@@ -7,30 +7,47 @@ from model.roots import Interface
 
 
 def addAxis(part, *args):
-    """Add an Axis feature to the Part and return Axis.
+    """Add an Axis feature to the Part.
 
-    Pass all args to Axis __init__ function.
+    .. function:: addAxis(part, p1, p2)
+
+    Args:
+        part (ModelAPI_Document): part document
+        p1 (Selection): first point
+        p2 (Selection): second point
+
+    .. function:: addAxis(part, face)
+
+    Args:
+        part (ModelAPI_Document): part document
+        face (Selection): cylindrical face
+
+    Returns:
+        Axis: axis object
     """
+    assert(args)
     feature = part.addFeature("Axis")
     return Axis(feature, *args)
 
 
 class Axis(Interface):
-    """Interface on an Axis feature."""
+    """Interface class for Axis feature.
 
-    def __init__(self, feature, *args):
-        """Initialize an Axis feature with given parameters.
+    .. function:: Axis(feature)
 
-        Expected arguments for all modes:
-        feature -- a Axis feature
+        Create interface for the feature without initialization.
 
-        For AxisByPointsCase mode (expect 2 arguments):
-        p1 -- FirstPoint
-        p2 -- SecondPoint
+    .. function:: Axis(feature, p1, p2)
 
-        For AxisByCylindricalFaceCase mode (expect 1 argument):
-        face -- CylindricalFace
-        """
+        Create interface for the feature and initialize the feature with arguments.
+
+    .. function:: Axis(feature, face)
+
+        Create interface for the feature and initialize the feature with arguments.
+    """
+
+    def __init__(self, feature, *args):
+        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
         Interface.__init__(self, feature)
         assert(self._feature.getKind() == "Axis")
 
@@ -47,18 +64,20 @@ class Axis(Interface):
         if not args:
             return
 
-        assert(len(args) == 2 or len(args) == 1)
+        assert(len(args) in (1, 2))
         if len(args) == 2:
             self.setPoints(*args)
         elif len(args) == 1:
             self.setCylindricalFace(*args)
+
+        self.execute()
         pass
 
     def __clear(self):
-        self._fill_attribute(self._CreationMethod, "AxisByPointsCase")
-        self._fill_attribute(self._FirstPoint, None)
-        self._fill_attribute(self._SecondPoint, None)
-        self._fill_attribute(self._CylindricalFace, None)
+        self._fillAttribute(self._CreationMethod, "AxisByPointsCase")
+        self._fillAttribute(self._FirstPoint, None)
+        self._fillAttribute(self._SecondPoint, None)
+        self._fillAttribute(self._CylindricalFace, None)
 
     def setPoints(self, p1, p2):
         """Modify points attribute of the feature.
@@ -66,9 +85,9 @@ class Axis(Interface):
         See __init__.
         """
         self.__clear()
-        self._fill_attribute(self._CreationMethod, "AxisByPointsCase")
-        self._fill_attribute(self._FirstPoint, p1)
-        self._fill_attribute(self._SecondPoint, p2)
+        self._fillAttribute(self._CreationMethod, "AxisByPointsCase")
+        self._fillAttribute(self._FirstPoint, p1)
+        self._fillAttribute(self._SecondPoint, p2)
         pass
 
     def setCylindricalFace(self, face):
@@ -77,6 +96,6 @@ class Axis(Interface):
         See __init__.
         """
         self.__clear()
-        self._fill_attribute(self._CreationMethod, "AxisByCylindricalFaceCase")
-        self._fill_attribute(self._CylindricalFace, face)
+        self._fillAttribute(self._CreationMethod, "AxisByCylindricalFaceCase")
+        self._fillAttribute(self._CylindricalFace, face)
         pass