From c63f1e7753cc42e6056fe954a2f6c0a05a19417d Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Mon, 20 Feb 2017 17:43:04 +0100 Subject: [PATCH] FEM: analysis object, move make def into make objects FEM module --- src/Mod/Fem/App/CMakeLists.txt | 1 - src/Mod/Fem/CMakeLists.txt | 1 - src/Mod/Fem/FemAnalysis.py | 38 ------------------------------ src/Mod/Fem/ObjectsFem.py | 7 ++++++ src/Mod/Fem/TestFem.py | 6 ++--- src/Mod/Fem/_CommandAnalysis.py | 4 ++-- src/Mod/Fem/importCcxFrdResults.py | 4 ++-- src/Mod/Fem/importVTKResults.py | 4 ++-- src/Mod/Fem/importZ88O2Results.py | 4 ++-- 9 files changed, 18 insertions(+), 51 deletions(-) delete mode 100644 src/Mod/Fem/FemAnalysis.py diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index a5fa84a19..38b5db4fd 100644 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -120,7 +120,6 @@ SET(FemScripts_SRCS importZ88O2Results.py Init.py InitGui.py - FemAnalysis.py FemBeamSection.py FemCommands.py FemConstraintSelfWeight.py diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index a38d57864..57d69d9cf 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -44,7 +44,6 @@ INSTALL( _TaskPanelShowResult.py TaskPanelShowResult.ui - FemAnalysis.py _CommandAnalysis.py FemMeshGmsh.py diff --git a/src/Mod/Fem/FemAnalysis.py b/src/Mod/Fem/FemAnalysis.py deleted file mode 100644 index 3e0897ebb..000000000 --- a/src/Mod/Fem/FemAnalysis.py +++ /dev/null @@ -1,38 +0,0 @@ -# *************************************************************************** -# * * -# * Copyright (c) 2013-2015 - Juergen Riegel * -# * * -# * This program is free software; you can redistribute it and/or modify * -# * it under the terms of the GNU Lesser General Public License (LGPL) * -# * as published by the Free Software Foundation; either version 2 of * -# * the License, or (at your option) any later version. * -# * for detail see the LICENCE text file. * -# * * -# * This program 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 Library General Public License for more details. * -# * * -# * You should have received a copy of the GNU Library General Public * -# * License along with this program; if not, write to the Free Software * -# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -# * USA * -# * * -# *************************************************************************** - -__title__ = "FEM Analysis managment" -__author__ = "Juergen Riegel" -__url__ = "http://www.freecadweb.org" - -## \addtogroup FEM -# @{ - -import FreeCAD - - -def makeFemAnalysis(name): - '''makeFemAnalysis(name): makes a Fem Analysis object''' - obj = FreeCAD.ActiveDocument.addObject("Fem::FemAnalysisPython", name) - return obj - -# @} diff --git a/src/Mod/Fem/ObjectsFem.py b/src/Mod/Fem/ObjectsFem.py index 488c93c5b..39c0edfc6 100644 --- a/src/Mod/Fem/ObjectsFem.py +++ b/src/Mod/Fem/ObjectsFem.py @@ -30,6 +30,13 @@ __url__ = "http://www.freecadweb.org" import FreeCAD +########## analysis ########## +def makeAnalysis(name): + '''makeAnalysis(name): makes a Fem Analysis object''' + obj = FreeCAD.ActiveDocument.addObject("Fem::FemAnalysisPython", name) + return obj + + ########## constraints ########## def makeConstraintBearing(name): '''makeConstraintBearing(name): makes a Fem ConstraintBearing object''' diff --git a/src/Mod/Fem/TestFem.py b/src/Mod/Fem/TestFem.py index 62a493bca..8ca2efe2d 100644 --- a/src/Mod/Fem/TestFem.py +++ b/src/Mod/Fem/TestFem.py @@ -27,7 +27,7 @@ import Fem import FemToolsCcx import FreeCAD -import FemAnalysis +import ObjectsFem import FemSolverCalculix import FemMaterial import csv @@ -82,7 +82,7 @@ class FemTest(unittest.TestCase): self.active_doc.recompute() def create_new_analysis(self): - self.analysis = FemAnalysis.makeFemAnalysis('Analysis') + self.analysis = ObjectsFem.makeAnalysis('Analysis') self.active_doc.recompute() def create_new_solver(self): @@ -304,7 +304,7 @@ class TherMechFemTest(unittest.TestCase): self.active_doc.recompute() def create_new_analysis(self): - self.analysis = FemAnalysis.makeFemAnalysis('Analysis') + self.analysis = ObjectsFem.makeAnalysis('Analysis') self.active_doc.recompute() def create_new_solver(self): diff --git a/src/Mod/Fem/_CommandAnalysis.py b/src/Mod/Fem/_CommandAnalysis.py index 9891faad0..f33cc6f93 100644 --- a/src/Mod/Fem/_CommandAnalysis.py +++ b/src/Mod/Fem/_CommandAnalysis.py @@ -46,9 +46,9 @@ class _CommandAnalysis(FemCommands): def Activated(self): FreeCAD.ActiveDocument.openTransaction("Create Analysis") FreeCADGui.addModule("FemGui") - FreeCADGui.addModule("FemAnalysis") + FreeCADGui.addModule("ObjectsFem") FreeCADGui.addModule("FemSolverCalculix") - FreeCADGui.doCommand("FemAnalysis.makeFemAnalysis('Analysis')") + FreeCADGui.doCommand("ObjectsFem.makeAnalysis('Analysis')") FreeCADGui.doCommand("FemGui.setActiveAnalysis(App.activeDocument().ActiveObject)") FreeCADGui.doCommand("FemSolverCalculix.makeFemSolverCalculix('CalculiX')") FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [App.activeDocument().ActiveObject]") diff --git a/src/Mod/Fem/importCcxFrdResults.py b/src/Mod/Fem/importCcxFrdResults.py index e4f296047..226c7c36b 100644 --- a/src/Mod/Fem/importCcxFrdResults.py +++ b/src/Mod/Fem/importCcxFrdResults.py @@ -70,8 +70,8 @@ def importFrd(filename, analysis=None, result_name_prefix=None): if(len(m['Nodes']) > 0): if analysis is None: analysis_name = os.path.splitext(os.path.basename(filename))[0] - import FemAnalysis - analysis_object = FemAnalysis.makeFemAnalysis('Analysis') + import ObjectsFem + analysis_object = ObjectsFem.makeAnalysis('Analysis') analysis_object.Label = analysis_name else: analysis_object = analysis # see if statement few lines later, if not analysis -> no FemMesh object is created ! diff --git a/src/Mod/Fem/importVTKResults.py b/src/Mod/Fem/importVTKResults.py index b76da5da5..6173d0742 100644 --- a/src/Mod/Fem/importVTKResults.py +++ b/src/Mod/Fem/importVTKResults.py @@ -78,8 +78,8 @@ def importVTK(filename, analysis=None, result_name_prefix=None): result_name_prefix = '' if analysis is None: analysis_name = os.path.splitext(os.path.basename(filename))[0] - import FemAnalysis - analysis_object = FemAnalysis.makeFemAnalysis('Analysis') + import ObjectsFem + analysis_object = ObjectsFem.makeAnalysis('Analysis') analysis_object.Label = analysis_name else: analysis_object = analysis diff --git a/src/Mod/Fem/importZ88O2Results.py b/src/Mod/Fem/importZ88O2Results.py index 6f4aff429..8e4608fc9 100644 --- a/src/Mod/Fem/importZ88O2Results.py +++ b/src/Mod/Fem/importZ88O2Results.py @@ -71,8 +71,8 @@ def import_z88_disp(filename, analysis=None, result_name_prefix=None): if(len(m['Nodes']) > 0): if analysis is None: analysis_name = os.path.splitext(os.path.basename(filename))[0] - import FemAnalysis - analysis_object = FemAnalysis.makeFemAnalysis('Analysis') + import ObjectsFem + analysis_object = ObjectsFem.makeAnalysis('Analysis') analysis_object.Label = analysis_name else: analysis_object = analysis # see if statement few lines later, if not analysis -> no FemMesh object is created !