"Transaction not closed" Error


I don’t know if this is the right forum to ask questions like the one i am about to ask here so please redirect me to another forum if needed.

I use the PyRevit toolbar to run Dynamo scripts and i am just getting into coding in python for revit and want to use the PyRevit toolbar to run the scripts.

I am trying to change the value of a parameter of a family instance but i get the following error:

I think it has something to do with the opening and/or closing of a transaction.
This is the code i use:

import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
import clr
from RevitServices.Transactions import TransactionManager
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
def flatten(l):
    return [item for sublist in l for item in sublist]

sel = uidoc.Selection.PickObjects(Selection.ObjectType.Element, 'Choose elements')
Parameter = []
for i in sel:
    SelElem = doc.GetElement(i)
    Parameter.append(SelElem.GetParameters("IfcGUID"))      #Parameter om uit te lezen

for i in flatten(Parameter):        
        #q = i.AsValueString()
        #if q == None:
        #    i.Set("Test1")
        q = i.AsString()
        if q == None:

I Found a Fix on this forum.

Hello @MelleH,

If you get a transaction error it is always the result of another error.
The transaction error itself will not help to solve the problem, but the error you get from pyRevit will help you. I sometimes overlook the pyRevit error because the window is minimized, so check for an error window if you ever get transaction errors.

1 Like