From 15e4fc25265691ac1fc254e4abf2487e75d88712 Mon Sep 17 00:00:00 2001 From: Dipin <26918585+dipinknair@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:30:06 -0500 Subject: [PATCH] Maint: New method of updating globals (#203) --- examples/basic/bolt_pretension.py | 18 ++---------------- .../fracture_analysis_contact_debonding.py | 18 ++---------------- examples/basic/harmonic_acoustics.py | 19 +------------------ examples/basic/modal_acoustics_analysis.py | 18 ++---------------- .../basic/steady_state_thermal_analysis.py | 18 ++---------------- .../topology_optimization_cantilever_beam.py | 18 ++---------------- examples/basic/valve.py | 18 ++---------------- .../Rotor_Blade_Inverse_solve.py | 2 +- .../conact_wear_simulation.py | 19 ++----------------- .../non_linear_analsis_rubber_boot_seal.py | 2 +- 10 files changed, 17 insertions(+), 133 deletions(-) diff --git a/examples/basic/bolt_pretension.py b/examples/basic/bolt_pretension.py index e4802f19..386b4cd9 100644 --- a/examples/basic/bolt_pretension.py +++ b/examples/basic/bolt_pretension.py @@ -27,7 +27,7 @@ # Embed mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) cwd = os.path.join(os.getcwd(), "out") @@ -525,21 +525,7 @@ def update(frame): # Project tree # ~~~~~~~~~~~~ - -def print_tree(node, indentation=""): - print(f"{indentation}├── {node.Name}") - - if ( - hasattr(node, "Children") - and node.Children is not None - and node.Children.Count > 0 - ): - for child in node.Children: - print_tree(child, indentation + "| ") - - -root_node = DataModel.Project -print_tree(root_node) +app.print_tree(DataModel.Project) # %% # Cleanup diff --git a/examples/basic/fracture_analysis_contact_debonding.py b/examples/basic/fracture_analysis_contact_debonding.py index 602e8124..72f65cb5 100644 --- a/examples/basic/fracture_analysis_contact_debonding.py +++ b/examples/basic/fracture_analysis_contact_debonding.py @@ -26,7 +26,7 @@ # Embed mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) cwd = os.path.join(os.getcwd(), "out") @@ -425,21 +425,7 @@ def write_file_contents_to_console(path): # Project tree # ~~~~~~~~~~~~ - -def print_tree(node, indentation=""): - print(f"{indentation}├── {node.Name}") - - if ( - hasattr(node, "Children") - and node.Children is not None - and node.Children.Count > 0 - ): - for child in node.Children: - print_tree(child, indentation + "| ") - - -root_node = DataModel.Project -print_tree(root_node) +app.print_tree(DataModel.Project) # %% # Cleanup diff --git a/examples/basic/harmonic_acoustics.py b/examples/basic/harmonic_acoustics.py index b2448ec0..08129fe6 100644 --- a/examples/basic/harmonic_acoustics.py +++ b/examples/basic/harmonic_acoustics.py @@ -498,24 +498,7 @@ def write_file_contents_to_console(path): # Project tree # ~~~~~~~~~~~~ - -def print_tree(node, indentation=""): - if hasattr(node, "Suppressed") and node.Suppressed is True: - print(f"{indentation}├── {node.Name} (Suppressed)") - else: - print(f"{indentation}├── {node.Name}") - - if ( - hasattr(node, "Children") - and node.Children is not None - and node.Children.Count > 0 - ): - for child in node.Children: - print_tree(child, indentation + "| ") - - -root_node = DataModel.Project -print_tree(root_node) +app.print_tree(DataModel.Project) # %% # Cleanup diff --git a/examples/basic/modal_acoustics_analysis.py b/examples/basic/modal_acoustics_analysis.py index 8166558a..6a2f3ac3 100644 --- a/examples/basic/modal_acoustics_analysis.py +++ b/examples/basic/modal_acoustics_analysis.py @@ -32,7 +32,7 @@ # Embed mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) cwd = os.path.join(os.getcwd(), "out") @@ -523,21 +523,7 @@ def update(frame): # Project tree # ~~~~~~~~~~~~ - -def print_tree(node, indentation=""): - print(f"{indentation}├── {node.Name}") - - if ( - hasattr(node, "Children") - and node.Children is not None - and node.Children.Count > 0 - ): - for child in node.Children: - print_tree(child, indentation + "| ") - - -root_node = DataModel.Project -print_tree(root_node) +app.print_tree(DataModel.Project) # %% # Cleanup diff --git a/examples/basic/steady_state_thermal_analysis.py b/examples/basic/steady_state_thermal_analysis.py index 88bc727d..0d3e1972 100644 --- a/examples/basic/steady_state_thermal_analysis.py +++ b/examples/basic/steady_state_thermal_analysis.py @@ -29,7 +29,7 @@ # Embed mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) cwd = os.path.join(os.getcwd(), "out") @@ -463,21 +463,7 @@ def write_file_contents_to_console(path): # Project tree # ~~~~~~~~~~~~ - -def print_tree(node, indentation=""): - print(f"{indentation}├── {node.Name}") - - if ( - hasattr(node, "Children") - and node.Children is not None - and node.Children.Count > 0 - ): - for child in node.Children: - print_tree(child, indentation + "| ") - - -root_node = DataModel.Project -print_tree(root_node) +app.print_tree(DataModel.Project) # %% # Cleanup diff --git a/examples/basic/topology_optimization_cantilever_beam.py b/examples/basic/topology_optimization_cantilever_beam.py index 53402b96..8f7c8291 100644 --- a/examples/basic/topology_optimization_cantilever_beam.py +++ b/examples/basic/topology_optimization_cantilever_beam.py @@ -23,7 +23,7 @@ # Embed Mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) @@ -252,21 +252,7 @@ def write_file_contents_to_console(path): # Project tree # ~~~~~~~~~~~~ - -def print_tree(node, indentation=""): - print(f"{indentation}├── {node.Name}") - - if ( - hasattr(node, "Children") - and node.Children is not None - and node.Children.Count > 0 - ): - for child in node.Children: - print_tree(child, indentation + "| ") - - -root_node = DataModel.Project -print_tree(root_node) +app.print_tree(DataModel.Project) # %% # Cleanup diff --git a/examples/basic/valve.py b/examples/basic/valve.py index 36cef93c..ceb267ef 100644 --- a/examples/basic/valve.py +++ b/examples/basic/valve.py @@ -23,7 +23,7 @@ # Embed mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) cwd = os.path.join(os.getcwd(), "out") @@ -252,21 +252,7 @@ def write_file_contents_to_console(path): # Project tree # ~~~~~~~~~~~~ - -def print_tree(node, indentation=""): - print(f"{indentation}├── {node.Name}") - - if ( - hasattr(node, "Children") - and node.Children is not None - and node.Children.Count > 0 - ): - for child in node.Children: - print_tree(child, indentation + "| ") - - -root_node = DataModel.Project -print_tree(root_node) +app.print_tree(DataModel.Project) # %% # Cleanup diff --git a/examples/technology_showcase/Rotor_Blade_Inverse_solve.py b/examples/technology_showcase/Rotor_Blade_Inverse_solve.py index 085107cf..16277979 100644 --- a/examples/technology_showcase/Rotor_Blade_Inverse_solve.py +++ b/examples/technology_showcase/Rotor_Blade_Inverse_solve.py @@ -58,7 +58,7 @@ # Embed mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) cwd = os.path.join(os.getcwd(), "out") diff --git a/examples/technology_showcase/conact_wear_simulation.py b/examples/technology_showcase/conact_wear_simulation.py index 7dea964a..cc6c5498 100644 --- a/examples/technology_showcase/conact_wear_simulation.py +++ b/examples/technology_showcase/conact_wear_simulation.py @@ -38,7 +38,7 @@ # Embed mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) cwd = os.path.join(os.getcwd(), "out") @@ -381,22 +381,7 @@ def update(frame): # Project tree # ~~~~~~~~~~~~ - -def print_tree(node, indentation=""): - print(f"{indentation}├── {node.Name}") - - if ( - hasattr(node, "Children") - and node.Children is not None - and node.Children.Count > 0 - ): - for child in node.Children: - print_tree(child, indentation + "| ") - - -root_node = DataModel.Project -print_tree(root_node) - +app.print_tree(DataModel.Project) # %% # Cleanup diff --git a/examples/technology_showcase/non_linear_analsis_rubber_boot_seal.py b/examples/technology_showcase/non_linear_analsis_rubber_boot_seal.py index b0077c35..6fd4cadf 100644 --- a/examples/technology_showcase/non_linear_analsis_rubber_boot_seal.py +++ b/examples/technology_showcase/non_linear_analsis_rubber_boot_seal.py @@ -31,7 +31,7 @@ # Embed mechanical and set global variables app = mech.App(version=241) -globals().update(mech.global_variables(app, True)) +app.update_globals(globals()) print(app) cwd = os.path.join(os.getcwd(), "out")