Skip to content

Commit

Permalink
REFACTOR: Improve try/except statements in _get_design_mesh_regions
Browse files Browse the repository at this point in the history
… and `_get_design_mesh_operations` (#4636)

Co-authored-by: Samuel Lopez <[email protected]>
  • Loading branch information
lorenzovecchietti and Samuelopez-ansys authored May 10, 2024
1 parent 34efaf7 commit 783657f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyaedt/modeler/modeler3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def create_3dcomponent(
else:
native_objs = [obj.name for _, v in self.user_defined_components.items() for _, obj in v.parts.items()]
objs = [obj for obj in self.object_names if obj not in native_objs]
if not native_components and native_objs:
if not native_components and native_objs and not auxiliary_dict:
self.logger.warning(
"Native component objects cannot be exported. Use native_components argument to"
" export an auxiliary dictionary file containing 3D components information"
Expand Down
18 changes: 14 additions & 4 deletions pyaedt/modules/MeshIcepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,13 @@ def _get_design_mesh_operations(self):
"Icepak",
)
)
except Exception as e:
self._app.logger.error(e)
except TypeError:
# design_properties not loaded, maybe there are mesh region, we need to warn the user
self._app.logger.warning("No mesh operation found.")
self._app.logger.debug("Failed to get mesh operation from `design_properties`.")
except KeyError:
# design_properties loaded, mesh region related keys missing, no need to warn the user
self._app.logger.debug("Failed to get mesh operation.")

return meshops

Expand Down Expand Up @@ -1104,8 +1109,13 @@ def _get_design_mesh_regions(self):
if el in meshop.__dict__:
meshop.__dict__[el] = dict_prop[el]
meshops.append(meshop)
except Exception as e:
self._app.logger.error(e)
except TypeError:
# design_properties not loaded, maybe there are mesh region, we need to warn the user
self._app.logger.warning("No mesh region found.")
self._app.logger.debug("Failed to get mesh region from `design_properties`.")
except KeyError:
# design_properties loaded, mesh region related keys missing, no need to warn the user
self._app.logger.debug("Failed to get mesh region.")

return meshops

Expand Down

0 comments on commit 783657f

Please sign in to comment.