Salome HOME
Update for macros NGO
authorNATHALIE GORE <ng13417n@dsp0897499.atlas.edf.fr>
Wed, 16 Oct 2019 09:06:54 +0000 (11:06 +0200)
committerNATHALIE GORE <ng13417n@dsp0897499.atlas.edf.fr>
Wed, 16 Oct 2019 09:06:54 +0000 (11:06 +0200)
src/PythonAddons/CMakeLists.txt
src/PythonAddons/Test/TestcompoundVertices.py [new file with mode: 0644]
src/PythonAddons/Test/TestimportParameters.py [new file with mode: 0644]
src/PythonAddons/macros/compoundVertices/compoundVertices.txt [new file with mode: 0644]
src/PythonAddons/macros/compoundVertices/feature.py
src/PythonAddons/macros/importParameters/importParameters.txt [new file with mode: 0644]

index 3597646b33b5cb3fb38ef45c28f7f999b5c27907..5a3cbb565af5b01d1d1e7c68c00d77fc598fcf3c 100644 (file)
@@ -47,4 +47,6 @@ INCLUDE(UnitTest)
 
 ADD_UNIT_TESTS(
   TestRectangle.py
+  TestcompoundVertices.py
+  TestimportParameters.py
 )
diff --git a/src/PythonAddons/Test/TestcompoundVertices.py b/src/PythonAddons/Test/TestcompoundVertices.py
new file mode 100644 (file)
index 0000000..72fc0c9
--- /dev/null
@@ -0,0 +1,52 @@
+# Copyright (C) 2014-2019  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
+#
+
+from salome.shaper import model
+from salome.shaper import geom
+from ModelAPI import *
+
+import os
+
+aSession = ModelAPI_Session.get()
+
+def getFilePath(fileName):
+    path = os.path.join(os.getenv("SHAPER_ROOT_DIR"), "bin", "salome", "macros", "compoundVertices")
+    return os.path.join(path, fileName)
+
+theFile = getFilePath("compoundVertices.txt")
+
+aSession.startOperation("Create part for import")
+aPartFeature = aSession.moduleDocument().addFeature("Part")
+aSession.finishOperation()
+aPart = aSession.activeDocument()
+
+aSession.startOperation("Import file")
+aFeatureKind = "compoundVertices"
+anImportFeature = aPart.addFeature(aFeatureKind)
+
+aFieldName = "file_path"
+file = anImportFeature.string(aFieldName)
+file.setValue(theFile)
+
+aSeparatorName = "separator"
+separator = anImportFeature.string(aSeparatorName)
+separator.setValue(" ")
+aSession.finishOperation()
+
+assert(model.checkPythonDump())
diff --git a/src/PythonAddons/Test/TestimportParameters.py b/src/PythonAddons/Test/TestimportParameters.py
new file mode 100644 (file)
index 0000000..3054c9b
--- /dev/null
@@ -0,0 +1,47 @@
+# Copyright (C) 2014-2019  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
+#
+
+from salome.shaper import model
+from salome.shaper import geom
+from ModelAPI import *
+
+import os
+
+aSession = ModelAPI_Session.get()
+
+def getFilePath(fileName):
+    path = os.path.join(os.getenv("SHAPER_ROOT_DIR"), "bin", "salome", "macros", "importParameters")
+    return os.path.join(path, fileName)
+
+theFile = getFilePath("importParameters.txt")
+
+aSession.startOperation("Create part for import")
+aPartFeature = aSession.moduleDocument().addFeature("Part")
+aSession.finishOperation()
+aPart = aSession.activeDocument()
+
+aSession.startOperation("Import file")
+aFeatureKind = "importParameters"
+anImportFeature = aPart.addFeature(aFeatureKind)
+aFieldName = "file_path"
+file = anImportFeature.string(aFieldName)
+file.setValue(theFile)
+aSession.finishOperation()
+
+assert(model.checkPythonDump())
diff --git a/src/PythonAddons/macros/compoundVertices/compoundVertices.txt b/src/PythonAddons/macros/compoundVertices/compoundVertices.txt
new file mode 100644 (file)
index 0000000..114b8bd
--- /dev/null
@@ -0,0 +1,18 @@
+21 16 224.00000000000003
+33 21 224.00000000000003
+35 38 224.00000000000003
+40 43 224.00000000000003
+53 43 224.00000000000003
+69 29 224.00000000000003
+97 58 224.00000000000003
+97 100 224.00000000000003
+80 127 224.00000000000003
+69 128 224.00000000000003
+63 116 224.00000000000003
+51 121 224.00000000000003
+44 137 224.00000000000003
+30 155 224.00000000000003
+23 158 224.00000000000003
+14 154 224.00000000000003
+18 76 224.00000000000003
+16 21 224.00000000000003
index 492594c4ae9eeec0d028f93159e55c388e70f570..d089f743431c41396bd2b66b4b18165a69898092 100644 (file)
@@ -83,8 +83,8 @@ class compoundVertices(model.Feature):
                         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)
diff --git a/src/PythonAddons/macros/importParameters/importParameters.txt b/src/PythonAddons/macros/importParameters/importParameters.txt
new file mode 100644 (file)
index 0000000..c5babe8
--- /dev/null
@@ -0,0 +1,4 @@
+a 10
+b 12
+c 15
+