Salome HOME
Merge remote-tracking branch 'origin/ngo/Lot5'
[modules/shaper.git] / src / PythonAddons / macros / compoundVertices / feature.py
index 0f2189c1ec2a7c6e18e10d804438f9c59e8fd807..492594c4ae9eeec0d028f93159e55c388e70f570 100644 (file)
@@ -2,6 +2,7 @@
 Author: Nathalie Gore
 """
 
+from qtsalome import QMessageBox
 from salome.shaper import model
 from salome.shaper import geom
 import ModelAPI
@@ -60,12 +61,12 @@ class compoundVertices(model.Feature):
 
         filepath = apath.value()
         if filepath != "" :
-            part = model.activeDocument()            
+            part = model.activeDocument()
             if self.lfeatures :
                 for feature in self.lfeatures:
                    part.removeFeature(feature.feature())
                 self.lfeatures = []
-                #part.removeFeature(self.folder.feature())
+                model.removeFolder(self.folder)
 
             from os.path import basename
             filename = basename(filepath)
@@ -77,6 +78,9 @@ class compoundVertices(model.Feature):
             with open(filepath) as file:
                 for line in file:
                     coord = line.split(self.separator)
+                    if len(coord) != 3:
+                        #QMessageBox.warning( self, 'Error!', '3D coords waited!' )
+                        return
                     x = float(coord[0]); y = float(coord[1]); z = float(coord[2]);
                     point = model.addPoint(part, x,y,z); point.execute(True); self.lfeatures.append(point)
                     vertex = model.addVertex(part, [point.result()]); vertex.execute(True); self.lfeatures.append(vertex)
@@ -88,7 +92,7 @@ class compoundVertices(model.Feature):
                 self.folder = model.addFolder(part, self.lfeatures[0], compound)
                 self.folder.setName(nameRes)
                 return
-        
+
             setError("The file does not exist")
 
     def isMacro(self):
@@ -98,4 +102,4 @@ class compoundVertices(model.Feature):
         compoundVertices feature is macro: removes itself on the creation transaction
         finish.
         """
-        return True
+        return False