]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix compoundVertices and adding list of parameters
authorNATHALIE GORE <ng13417n@dsp0897499.atlas.edf.fr>
Fri, 9 Aug 2019 13:30:16 +0000 (15:30 +0200)
committervsv <vsv@opencascade.com>
Wed, 6 Nov 2019 08:22:42 +0000 (11:22 +0300)
src/PythonAddons/addons_Features.xml.in
src/PythonAddons/macros/compoundVertices/feature.py
src/PythonAddons/macros/compoundVertices/widget.xml
src/PythonAddons/macros/importParameters/__init__.py [new file with mode: 0644]
src/PythonAddons/macros/importParameters/feature.py [new file with mode: 0644]
src/PythonAddons/macros/importParameters/widget.xml [new file with mode: 0644]

index 958ef4511f40361f5dde82f753d14f4b378c0702..1bbec06757d9953e28fd5f24a29ce7a10e1e9822 100644 (file)
@@ -1,5 +1,6 @@
 <plugin>
   <source path="@ADDONS_FOLDER_PATH@/macros/rectangle/widget.xml"/>
   <source path="@ADDONS_FOLDER_PATH@/macros/compoundVertices/widget.xml"/>
+  <source path="@ADDONS_FOLDER_PATH@/macros/importParameters/widget.xml"/>
   <source path="@ADDONS_FOLDER_PATH@/macros/box/widget.xml"/>
 </plugin>
index 141b35bb04129aac39e2a4a4ef4578dc9560f131..91bc6017f3dd90119258d8248ef8fdaae2a1d780 100644 (file)
@@ -56,13 +56,11 @@ class compoundVertices(model.Feature):
                 for line in file:
                     coord = line.split(' ')
                     x = float(coord[0]); y = float(coord[1]); z = float(coord[2]);
-                    print(line)
                     point = model.addPoint(part, x,y,z)
-                    print(line)
                     vertex = model.addVertex(part, [point.result()])
-                    print(line)
-                    #lVertices.append(vertex)
+                    lVertices.append(vertex.result())
                 file.close()
+                Compound_1 = model.addCompound(part, lVertices)
                 return
         
             setError("The file does not exist")
index d7901cf223bc8357f95f53af4642b1777321abdc..e8e2f2e8855070a79cb7184cdb2606ea3b777fb1 100644 (file)
@@ -4,7 +4,6 @@
 \r
       <feature id="compoundVertices" title="Points set" tooltip="Import a set of construction points" icon="icons/import.png">\r
         <file_selector id="file_path" title="Import file" path="">\r
-          <validator id="GeomValidators_Positive"/>\r
         </file_selector>\r
       </feature>\r
 \r
diff --git a/src/PythonAddons/macros/importParameters/__init__.py b/src/PythonAddons/macros/importParameters/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/PythonAddons/macros/importParameters/feature.py b/src/PythonAddons/macros/importParameters/feature.py
new file mode 100644 (file)
index 0000000..440eca6
--- /dev/null
@@ -0,0 +1,63 @@
+"""importParameters
+Author: Nathalie Gore
+"""
+
+from salome.shaper import model
+from salome.shaper import geom
+import ModelAPI
+
+class importParameters(model.Feature):
+    """Import of Construction points
+    """
+
+# Feature initializations
+
+    def __init__(self):
+        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
+        model.Feature.__init__(self)
+
+    @staticmethod
+    def ID():
+        """Return Id of the Feature."""
+        return "importParameters"
+
+    @staticmethod
+    def FILE_ID():
+        """Returns ID of the file select parameter."""
+        return "file_path"
+
+    def getKind(self):
+        """Override Feature.getKind()"""
+        return importParameters.ID()
+
+
+# Initialization of the dialog panel
+
+    def initAttributes(self):
+        """Override Feature.initAttributes()"""
+        # Creating the input argument of the feature
+        self.data().addAttribute(self.FILE_ID(), ModelAPI.ModelAPI_AttributeString_typeId())
+
+# Execution of the Import
+
+    def execute(self):
+        """F.execute() -- execute the Feature"""
+        # Retrieving the user input
+        apath    = self.string(self.FILE_ID())
+        filepath = apath.value()
+        #print("filepath : ", filepath)
+        if filepath != "" :
+
+            # Creating the parameters in the current document
+            part = model.activeDocument()
+
+            with open(filepath) as file:
+                for line in file:
+                    defParameters = line.replace("\n","").split(' ')
+                    if len(defParameters) == 2 :
+                        model.addParameter(part, defParameters[0], defParameters[1])
+                file.close()
+                return
+        
+            setError("The file does not exist")
+                       
diff --git a/src/PythonAddons/macros/importParameters/widget.xml b/src/PythonAddons/macros/importParameters/widget.xml
new file mode 100644 (file)
index 0000000..e43b86a
--- /dev/null
@@ -0,0 +1,12 @@
+<source>\r
+  <workbench id="Macros" document="Part">\r
+    <group id="Samples">\r
+\r
+      <feature id="importParameters" title="List of Parameters" tooltip="Import a set of parameters" icon="icons/import.png">\r
+        <file_selector id="file_path" title="Import file" path="">\r
+        </file_selector>\r
+      </feature>\r
+\r
+    </group>\r
+  </workbench>  \r
+</source>\r