From 22e990073a20781abd4bea4d0324562a33a1eedc Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 6 Jun 2017 16:56:09 +0100 Subject: [PATCH] FEM: input writer, constraint force, move the refshape type code into fem tools --- src/Mod/Fem/FemInputWriter.py | 10 ---------- src/Mod/Fem/FemTools.py | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Mod/Fem/FemInputWriter.py b/src/Mod/Fem/FemInputWriter.py index 204f060ea3..8a34560377 100644 --- a/src/Mod/Fem/FemInputWriter.py +++ b/src/Mod/Fem/FemInputWriter.py @@ -118,16 +118,6 @@ class FemInputWriter(): # check shape type of reference shape for femobj in self.force_objects: # femobj --> dict, FreeCAD document object is femobj['Object'] frc_obj = femobj['Object'] - # in GUI defined frc_obj all ref_shape have the same shape type - # TODO in FemTools: check if all RefShapes really have the same type an write type to dictionary - femobj['RefShapeType'] = '' - if frc_obj.References: - first_ref_obj = frc_obj.References[0] - first_ref_shape = first_ref_obj[0].Shape.getElement(first_ref_obj[1][0]) - femobj['RefShapeType'] = first_ref_shape.ShapeType - else: - # frc_obj.References could be empty ! # TODO in FemTools: check - FreeCAD.Console.PrintError('At least one Force Object has empty References!\n') if femobj['RefShapeType'] == 'Vertex': # print("load on vertices --> we do not need the femelement_table and femnodes_mesh for node load calculation") pass diff --git a/src/Mod/Fem/FemTools.py b/src/Mod/Fem/FemTools.py index b6ccc9f545..be7f225c1d 100644 --- a/src/Mod/Fem/FemTools.py +++ b/src/Mod/Fem/FemTools.py @@ -269,6 +269,7 @@ class FemTools(QtCore.QRunnable, QtCore.QObject): elif m.isDerivedFrom("Fem::ConstraintForce"): force_constraint_dict = {} force_constraint_dict['Object'] = m + force_constraint_dict['RefShapeType'] = get_refshape_type(m) self.force_constraints.append(force_constraint_dict) elif m.isDerivedFrom("Fem::ConstraintPressure"): PressureObjectDict = {} @@ -577,4 +578,25 @@ class FemTools(QtCore.QRunnable, QtCore.QObject): stats = match[result_type] return stats + +# helper +def get_refshape_type(fem_doc_object): + # returns the reference shape type + # for force object: + # in GUI defined frc_obj all frc_obj have at leas one ref_shape and ref_shape have all the same shape type + # for material object: + # in GUI defined material_obj could have no RefShape and RefShapes could be different type + # we gone need the RefShapes to be the same type inside one fem_doc_object + # TODO here: check if all RefShapes inside the object really have the same type + import FemMeshTools + if hasattr(fem_doc_object, 'References') and fem_doc_object.References: + first_ref_obj = fem_doc_object.References[0] + first_ref_shape = FemMeshTools.get_element(first_ref_obj[0], first_ref_obj[1][0]) + st = first_ref_shape.ShapeType + print(fem_doc_object.Name + ' has ' + st + ' reference shapes.') + return st + else: + print(fem_doc_object.Name + ' has empty References.') + return '' + ## @}