@@ -160,8 +160,7 @@ def display_image(image_name):
160160# -----------------------------------
161161#
162162
163- mechanical .run_python_script (
164- """
163+ mechanical .run_python_script ("""
165164ExtAPI.Graphics.Camera.SetSpecificViewOrientation(
166165 Ansys.Mechanical.DataModel.Enums.ViewOrientationType.Iso
167166)
@@ -175,16 +174,14 @@ def display_image(image_name):
175174settings_720p.Width = 1280
176175settings_720p.Height = 720
177176settings_720p.CurrentGraphicsDisplay = False
178- """
179- )
177+ """ )
180178
181179###############################################################################
182180# Import geometry
183181# ---------------
184182#
185183
186- mechanical .run_python_script (
187- """
184+ mechanical .run_python_script ("""
188185import os
189186geometry_import_group = Model.GeometryImportGroup
190187geometry_import = geometry_import_group.AddGeometryImport()
@@ -204,8 +201,7 @@ def display_image(image_name):
204201ExtAPI.Graphics.ExportImage(
205202 os.path.join(project_directory, "geometry.png"), image_export_format, settings_720p
206203)
207- """
208- )
204+ """ )
209205
210206# Download the geometry image and display it
211207mechanical .download (files = os .path .join (project_directory , "geometry.png" ), target_dir = OUTPUT_DIR )
@@ -217,8 +213,7 @@ def display_image(image_name):
217213# Import material, assign it to the bodies and create Named Selections
218214# --------------------------------------------------------------------
219215#
220- mechanical .run_python_script (
221- """
216+ mechanical .run_python_script ("""
222217materials = ExtAPI.DataModel.Project.Model.Materials
223218materials.Import(material_path)
224219materials.RefreshMaterials()
@@ -255,15 +250,13 @@ def display_image(image_name):
255250EM_OUTER_SURFACE_NS = [x for x in ExtAPI.DataModel.Tree.AllObjects if x.Name == "em_outer_surface"][
256251 0
257252]
258- """
259- )
253+ """ )
260254
261255###############################################################################
262256# Set up the mesh and generate
263257# ----------------------------
264258#
265- mechanical .run_python_script (
266- """
259+ mechanical .run_python_script ("""
267260MESH = Model.Mesh
268261
269262MESH.UseAdaptiveSizing = True
@@ -278,8 +271,7 @@ def display_image(image_name):
278271ExtAPI.Graphics.ExportImage(
279272 os.path.join(project_directory, "mesh.png"), image_export_format, settings_720p
280273)
281- """
282- )
274+ """ )
283275
284276# Download the mesh image and display it
285277mechanical .download (files = os .path .join (project_directory , "mesh.png" ), target_dir = OUTPUT_DIR )
@@ -291,8 +283,7 @@ def display_image(image_name):
291283# ---------------------------------------------------------------
292284#
293285
294- mechanical .run_python_script (
295- """
286+ mechanical .run_python_script ("""
296287Model.AddTransientThermalAnalysis()
297288
298289# Store all main tree nodes as variables
@@ -475,23 +466,19 @@ def display_image(image_name):
475466group_list = [External_Convection_Load_1, External_Convection_Load_2, External_Convection_Load_3]
476467grouping_folder = Tree.Group(group_list)
477468tree_grouping_folder_70 = DataModel.GetObjectsByName("New Folder")
478- """
479- )
469+ """ )
480470
481471###############################################################################
482472# Use the output from Fluent to import the temperature and HTC data
483473# -----------------------------------------------------------------
484474#
485475# Add imported convection
486- result = mechanical .run_python_script (
487- """
476+ result = mechanical .run_python_script ("""
488477Imported_Load_Group = TRANS_THERM.AddImportedLoadExternalData()
489478imported_load_group_61=Imported_Load_Group
490479imported_convection_62 = Imported_Load_Group.AddImportedConvection()
491- """
492- )
493- result = mechanical .run_python_script (
494- """
480+ """ )
481+ result = mechanical .run_python_script ("""
495482external_data_files = Ansys.Mechanical.ExternalData.ExternalDataFileCollection()
496483external_data_files.SaveFilesWithProject = False
497484
@@ -604,11 +591,9 @@ def display_image(image_name):
604591)
605592
606593imported_load_group_61.ImportExternalDataFiles(external_data_files)
607- """
608- )
594+ """ )
609595
610- result = mechanical .run_python_script (
611- """
596+ result = mechanical .run_python_script ("""
612597table = imported_load_group_61.Children[0].GetTableByName("Film Coefficient")
613598numofsteps = 15
614599Film_Coeff = [
@@ -638,20 +623,17 @@ def display_image(image_name):
638623imported_convection_62.Location = selection
639624imported_load_id = imported_convection_62.ObjectId
640625imported_load = DataModel.GetObjectById(imported_load_id)
641- """
642- )
626+ """ )
643627
644- mechanical .run_python_script (
645- """
628+ mechanical .run_python_script ("""
646629imported_load.ImportLoad()
647630
648631Tree.Activate([imported_load])
649632ExtAPI.Graphics.Camera.SetFit()
650633ExtAPI.Graphics.ExportImage(
651634 os.path.join(project_directory, "imported_temperature.png"), image_export_format, settings_720p
652635)
653- """
654- )
636+ """ )
655637mechanical .download (
656638 files = os .path .join (project_directory , "imported_temperature.png" ), target_dir = OUTPUT_DIR
657639)
@@ -662,8 +644,7 @@ def display_image(image_name):
662644# Solve and post-process the results
663645# ----------------------------------
664646#
665- mechanical .run_python_script (
666- """
647+ mechanical .run_python_script ("""
667648# Insert results objects
668649
669650Temp = TRANS_THERM_SOLN.AddTemperature()
@@ -683,8 +664,7 @@ def display_image(image_name):
683664ExtAPI.Graphics.ExportImage(
684665 os.path.join(project_directory, "temperature.png"), image_export_format, settings_720p
685666)
686- """
687- )
667+ """ )
688668
689669# Download the temperature image and display it
690670mechanical .download (files = os .path .join (project_directory , "temperature.png" ), target_dir = OUTPUT_DIR )
@@ -696,8 +676,7 @@ def display_image(image_name):
696676# Setup Structural Analysis
697677# -------------------------
698678#
699- mechanical .run_python_script (
700- """
679+ mechanical .run_python_script ("""
701680Model.AddStaticStructuralAnalysis()
702681
703682# Define analysis settings
@@ -756,15 +735,13 @@ def display_image(image_name):
756735Fixed_Support = STAT_STRUC.AddFixedSupport()
757736selection = NS_GRP.Children[3]
758737Fixed_Support.Location = selection
759- """
760- )
738+ """ )
761739
762740###############################################################################
763741# Solve and post-process the results
764742# ----------------------------------
765743#
766- mechanical .run_python_script (
767- """
744+ mechanical .run_python_script ("""
768745SOLN = STAT_STRUC.Solution
769746
770747TOT_DEF1 = SOLN.AddTotalDeformation()
@@ -803,8 +780,7 @@ def display_image(image_name):
803780ExtAPI.Graphics.ExportImage(
804781 os.path.join(project_directory, "plastic_strain.png"), image_export_format, settings_720p
805782)
806- """
807- )
783+ """ )
808784
809785# Download the results images to local directory
810786mechanical .download (files = os .path .join (project_directory , "deformation.png" ), target_dir = OUTPUT_DIR )
0 commit comments