From: NATHALIE GORE Date: Wed, 16 Oct 2019 09:06:54 +0000 (+0200) Subject: Update for macros NGO X-Git-Tag: V9_5_0a1~167^2~35 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=56c85340f8b5aab5d84356838496ea6c1104b0bf;p=modules%2Fshaper.git Update for macros NGO --- diff --git a/src/PythonAddons/CMakeLists.txt b/src/PythonAddons/CMakeLists.txt index 3597646b3..5a3cbb565 100644 --- a/src/PythonAddons/CMakeLists.txt +++ b/src/PythonAddons/CMakeLists.txt @@ -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 index 000000000..72fc0c961 --- /dev/null +++ b/src/PythonAddons/Test/TestcompoundVertices.py @@ -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 index 000000000..3054c9b29 --- /dev/null +++ b/src/PythonAddons/Test/TestimportParameters.py @@ -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 index 000000000..114b8bd4f --- /dev/null +++ b/src/PythonAddons/macros/compoundVertices/compoundVertices.txt @@ -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 diff --git a/src/PythonAddons/macros/compoundVertices/feature.py b/src/PythonAddons/macros/compoundVertices/feature.py index 517978dc0..a1d457ad2 100644 --- a/src/PythonAddons/macros/compoundVertices/feature.py +++ b/src/PythonAddons/macros/compoundVertices/feature.py @@ -81,8 +81,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 index 000000000..c5babe823 --- /dev/null +++ b/src/PythonAddons/macros/importParameters/importParameters.txt @@ -0,0 +1,4 @@ +a 10 +b 12 +c 15 +