From: NATHALIE GORE Date: Fri, 9 Aug 2019 13:30:16 +0000 (+0200) Subject: Fix compoundVertices and adding list of parameters X-Git-Tag: V9_5_0a1~167^2~70 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eb1fd738b4975723d9ac678e53c7c88b89f70629;p=modules%2Fshaper.git Fix compoundVertices and adding list of parameters --- diff --git a/src/PythonAddons/addons_Features.xml.in b/src/PythonAddons/addons_Features.xml.in index 958ef4511..1bbec0675 100644 --- a/src/PythonAddons/addons_Features.xml.in +++ b/src/PythonAddons/addons_Features.xml.in @@ -1,5 +1,6 @@ + diff --git a/src/PythonAddons/macros/compoundVertices/feature.py b/src/PythonAddons/macros/compoundVertices/feature.py index 141b35bb0..91bc6017f 100644 --- a/src/PythonAddons/macros/compoundVertices/feature.py +++ b/src/PythonAddons/macros/compoundVertices/feature.py @@ -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") diff --git a/src/PythonAddons/macros/compoundVertices/widget.xml b/src/PythonAddons/macros/compoundVertices/widget.xml index d7901cf22..e8e2f2e88 100644 --- a/src/PythonAddons/macros/compoundVertices/widget.xml +++ b/src/PythonAddons/macros/compoundVertices/widget.xml @@ -4,7 +4,6 @@ - diff --git a/src/PythonAddons/macros/importParameters/__init__.py b/src/PythonAddons/macros/importParameters/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/PythonAddons/macros/importParameters/feature.py b/src/PythonAddons/macros/importParameters/feature.py new file mode 100644 index 000000000..440eca6e1 --- /dev/null +++ b/src/PythonAddons/macros/importParameters/feature.py @@ -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 index 000000000..e43b86afe --- /dev/null +++ b/src/PythonAddons/macros/importParameters/widget.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + +