FEM: meshtools and dependent modules, add error message for retrieving solid elements if out of range

This commit is contained in:
Bernd Hahnebach
2018-05-21 14:31:45 +02:00
committed by wmayer
parent 1e497ebd8e
commit 458a4be12f
2 changed files with 9 additions and 1 deletions

View File

@@ -204,6 +204,9 @@ class _TaskPanelFemMaterial:
ref_shty = ''
for ref in self.references:
r = FemMeshTools.get_element(ref[0], ref[1]) # the method getElement(element) does not return Solid elements
if not r:
FreeCAD.Console.PrintError('Problem in retrieving element: {} \n'.format(ref[1]))
continue
# print(' ReferenceShape : ', r.ShapeType, ', ', ref[0].Name, ', ', ref[0].Label, ' --> ', ref[1])
if not ref_shty:
ref_shty = r.ShapeType

View File

@@ -1449,7 +1449,12 @@ def is_same_geometry(shape1, shape2):
def get_element(part, element):
if element.startswith('Solid'):
return part.Shape.Solids[int(element.lstrip('Solid')) - 1] # Solid
index = int(element.lstrip('Solid')) - 1
if index >= len(part.Shape.Solids):
FreeCAD.Console.PrintError('Index out of range. This Solid does not exist in the Shape!\n')
return None
else:
return part.Shape.Solids[index] # Solid
else:
return part.Shape.getElement(element) # Face, Edge, Vertex