]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add field in macro
authorNATHALIE GORE <ng13417n@dsp0897499.atlas.edf.fr>
Mon, 19 Aug 2019 14:49:57 +0000 (16:49 +0200)
committerNATHALIE GORE <ng13417n@dsp0897499.atlas.edf.fr>
Mon, 19 Aug 2019 14:49:57 +0000 (16:49 +0200)
src/PythonAddons/macros/compoundVertices/feature.py

index d6b5869f3f6e8b94585086458f98ad62fdee2b4f..3f5a3e3f1bf53febd09a27c0557b9346870f218b 100644 (file)
@@ -47,20 +47,30 @@ class compoundVertices(model.Feature):
         filepath = apath.value()
         print("filepath : ", filepath)
         if filepath != "" :
+            
+            from os.path import basename
+            filename = basename(filepath)
+            print("filename : ", filename)
 
             # Creating the construction points in the current document
             part = model.activeDocument()
             lVertices = []
 
+            startPoint = None
+
             with open(filepath) as file:
                 for line in file:
                     coord = line.split(' ')
                     x = float(coord[0]); y = float(coord[1]); z = float(coord[2]);
                     point = model.addPoint(part, x,y,z); point.execute(True)
+                    if startPoint == None : startPoint = point
                     vertex = model.addVertex(part, [point.result()]); vertex.execute(True)
                     lVertices.append(vertex.result())
                 file.close()
-                Compound_1 = model.addCompound(part, lVertices)
+                compound = model.addCompound(part, lVertices)
+                compound.execute(True)
+                folder = model.addFolder(part, startPoint, compound)
+                folder.setName(filename)
                 return
         
             setError("The file does not exist")