Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REFACTOR: Improve try/except statements in _get_design_mesh_regions and _get_design_mesh_operations #4636

Merged
merged 5 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading