Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
[modules/shaper.git] / src / PythonFeaturesPlugin / FeaturesAPI.py
index feef52528b6a757a377c499b049fbb8cca45e2a2..f47ba3f705d9d9726a21d3d2383fa96d39049d84 100644 (file)
@@ -2,41 +2,46 @@ from ModelAPI import *
 from GeomDataAPI import *
 from GeomAlgoAPI import *
 
-# NOTE : I think this style should be chosen 
+# NOTE : I think this style should be chosen
 # for function as recommended by Python programming
 # standards
-def build_face_from_sketch (sketch, edges=None) :
-  # If no edges have been selected, get the whole sketch 
-  # edges
-  if edges == None:
-    result = sketch.firstResult()
-    edges  = modelAPI_ResultConstruction(result).shape()
-  
-  # Build the face
-  origin = geomDataAPI_Point( sketch.attribute("Origin") ).pnt()
-  dirX   = geomDataAPI_Dir( sketch.attribute("DirX") ).dir()
-  dirY   = geomDataAPI_Dir( sketch.attribute("DirY") ).dir()
-  normal = geomDataAPI_Dir( sketch.attribute("Norm") ).dir()
-  faces  = ShapeList()
-  GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, dirY, normal, edges, faces)
-  return faces[0]
+
+
+def build_face_from_sketch(sketch, edges=None):
+    # If no edges have been selected, get the whole sketch
+    # edges
+    if edges == None:
+        result = sketch.firstResult()
+        edges = modelAPI_ResultConstruction(result).shape()
+
+    # Build the face
+    origin = geomDataAPI_Point(sketch.attribute("Origin")).pnt()
+    dirX = geomDataAPI_Dir(sketch.attribute("DirX")).dir()
+    dirY = geomDataAPI_Dir(sketch.attribute("DirY")).dir()
+    normal = geomDataAPI_Dir(sketch.attribute("Norm")).dir()
+    faces = ShapeList()
+    GeomAlgoAPI_SketchBuilder.createFaces(
+        origin, dirX, dirY, normal, edges, faces)
+    return faces[0]
 
 # NOTE : with an optional argument it is not
 # a so good idea to put part as last argument
 # it would result in a mandatory argument
 # put after an optionnal one
+
+
 def addExtrusion(part, sketch, size, reverse=False, subshapes=None):
-  feature = part.addFeature("Extrusion")
-  
-  # Build apropriate face
-  face = build_face_from_sketch(sketch, subshapes)
-  # Get sketch result
-  sketchResult = sketch.firstResult()
-  
-  # Set attributes and execute the feature
-  feature.selection("extrusion_face").setValue(sketchResult, face)
-  feature.real("extrusion_size").setValue(size)
-  feature.boolean("extrusion_reverse").setValue(False)
-  feature.execute()
-  
-  return feature
+    feature = part.addFeature("Extrusion")
+
+    # Build apropriate face
+    face = build_face_from_sketch(sketch, subshapes)
+    # Get sketch result
+    sketchResult = sketch.firstResult()
+
+    # Set attributes and execute the feature
+    feature.selection("extrusion_face").setValue(sketchResult, face)
+    feature.real("extrusion_size").setValue(size)
+    feature.boolean("extrusion_reverse").setValue(False)
+    feature.execute()
+
+    return feature