]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PythonAddons/macros/compoundVertices/feature.py
Salome HOME
Copyright update 2021
[modules/shaper.git] / src / PythonAddons / macros / compoundVertices / feature.py
index 0f2189c1ec2a7c6e18e10d804438f9c59e8fd807..a8ffe0e7ba186ae6ff9876b739804300622c00f7 100644 (file)
@@ -1,3 +1,22 @@
+# Copyright (C) 2016-2021  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 """compound of vertices Feature
 Author: Nathalie Gore
 """
@@ -60,12 +79,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,10 +96,12 @@ class compoundVertices(model.Feature):
             with open(filepath) as file:
                 for line in file:
                     coord = line.split(self.separator)
+                    if len(coord) != 3:
+                        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)
-                    lVertices.append(vertex.result())
+                    #vertex = model.addVertex(part, [point.result()]); vertex.execute(True); self.lfeatures.append(vertex)
+                    lVertices.append(point.result())
                 file.close()
                 compound = model.addCompound(part, lVertices)
                 compound.execute(True); self.lfeatures.append(compound)
@@ -88,7 +109,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 +119,4 @@ class compoundVertices(model.Feature):
         compoundVertices feature is macro: removes itself on the creation transaction
         finish.
         """
-        return True
+        return False