I wrote the following code to extract some results from Abaqus. I get an indentation error when I run the code. I have 19 simulation and I want to use this code to extract the results that I want. I have tried to fix it, but I couldn't. Can anyone help me and tell me what the problem is?
import os
from abaqus import *
from abaqusConstants import *
from viewerModules import *
from driverUtils import executeOnCaeStartup
# Function to create a new folder if it does not exist
def create_folder_if_not_exists(directory):
if not os.path.exists(directory):
os.makedirs(directory)
# Loop to process each ODB file
for i in range(1, 20):
odb_path = 'D:/Majid/Solder Project-LG/2023-05-25-Final simulation/Warpage file number #5/19 location-New/Load -20%/'
odb_filename = '0i.odb'
odb_fullpath = os.path.join(odb_path, odb_filename)
# Open the ODB file
o2 = session.openOdb(name=odb_fullpath)
odb_basename = os.path.splitext(odb_filename)[0] # Get the base name without extension
# Set up the viewport
session.Viewport(name='Viewport: 1', origin=(0.0, 0.0), width=162.0, height=189.25)
session.viewports['Viewport: 1'].makeCurrent()
session.viewports['Viewport: 1'].maximize()
session.viewports['Viewport: 1'].setValues(displayedObject=o2)
session.viewports['Viewport: 1'].odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF, ))
# Function to export field report
def export_field_report(surface_sets, report_filename):
leaf = dgo.LeafFromSurfaceSets(surfaceSets=surface_sets)
session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)
odb = session.odbs[odb_fullpath]
create_folder_if_not_exists(os.path.join(odb_path, odb_basename))
report_file_path = os.path.join(odb_path, odb_basename, report_filename)
session.writeFieldReport(fileName=report_file_path, append=OFF, sortItem='Node Label', odb=odb, step=5, frame=9,
outputPosition=NODAL, variable=(('COORD', NODAL, ((COMPONENT, 'COOR1'), (COMPONENT, 'COOR2'), (COMPONENT, 'COOR3'), )), ),
stepFrame=SPECIFY)
# Export field reports for different surface sets
export_field_report(("Bottom surf of stencil", ), 'Stencil-last-INC.rpt')
export_field_report(("PREPREG-UPPER", ), 'Board-last-INC.rpt')
export_field_report(("Upper surf of stencil", ), 'Upper-Surf-Stencil-last-INC.rpt')
I have imported this code in chatgpt but I couldn't fix it.