I cant figure out why revit is giving me a transaction error on the following.
I only have one transaction at the end of my code. (if i remove any reference to revit or autodesk and just print the variables instead of trying to update the parameters within revit the code works as intended.
Basically what the code is doing is grabbing an address out of a file. Grabbing the suburb and looking up a postcode and state and adding it to the text and then trying to insert it into the project address field within revit.
from Autodesk.Revit.DB import * import csv import time import os import re keywords = ['Unit', 'Lot', 'Villa', 'No.'] suburb = False #this gets the appdata location from the OS appdata = os.getenv('APPDATA') doc = __revit__.ActiveUIDocument.Document project_info = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ProjectInformation).ToElements() file = open(appdata + "\LGX\programSettings.txt") #this imports all the lines in the file to a variable project_data_import = file.readlines() project_number = project_data_import address = project_data_import[10:] file.close() if ',' in address: address_1 = address.rsplit(',') address_1[-1] = ''.join(address_1[-1].split(' ', 1)) if ' ' in address_1[-1]: multi_suburb = True multi_word_suburb_check = address_1[-1] address = address.replace(',', ' ').split(' ') else: multi_suburb = False address = address.replace(',', ' ').split(' ') else: address = address.split(' ') clean_address =  for i in address: if i.strip(): clean_address.append(i) address = clean_address address_count = len(address) if multi_suburb == True: suburb_check = multi_word_suburb_check else: suburb_check = address[address_count - 1] try: number_check = int(address) except ValueError: number_check = '' line_4 =  line_1 = '' line_2 = '' line_3 = '' suburb_check = suburb_check.upper().rstrip('\n') reader = csv.reader(open("C:/test/australian_postcodes.csv", 'r')) for row in reader: if row == suburb_check: line_4.append(row) line_4.append(row) line_3 = suburb_check line_4 = ', '.join(line_4) suburb_word_count = len(suburb_check.split(' ')) suburb = True for x in range(suburb_word_count): address.pop() if suburb == False: line_4 = '' #print('suburb not found') result =  for i in keywords: if i in address: result.append(address.index(i)) if result != : line_1 = ' '.join(address[min(result):max(result) + 2]) if multi_suburb == True: line_2 = ' '.join(address[max(result) + 2:address_count - 1]) else: line_2 = ' '.join(address[max(result) + 2:address_count - 1]) elif isinstance(number_check, int): line_1 = ''.join(address) line_1 = 'No. ' + line_1 line_2 = ' '.join(address[1:]) elif suburb == True: line_1 = ' '.join(address) else: line_1 = ' '.join(address) address = str(line_1.upper() + "\n" + line_2.upper() + '\n' + line_3.upper() + '\n' + line_4.upper()) t = Transaction(doc, 'Fill in titleblock') t.Start() project_info.Number = project_number project_info.Address = address t.Commit()