RIR Python - Transaction Name

Hi guys,

I can’t see my transaction name in Undo button eventhough I set a name for the transaction. For instance:

with DB.Transaction(doc, "My Transaction Name here") as t:
    "Code Here"

I have set the transaction name as “My Transaction Name here” above. But when I check Revit interface, it shows a Grasshopper action.

Any idea why I get this?

I think you need to make an actual change to the document.

“Code here” meant a change I do in the document. Code down below is an example:

import clr

from System import Enum

import rhinoscriptsyntax as rs
import Rhino
import RhinoInside
import Grasshopper
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
from RhinoInside.Revit import Revit, Convert
from Autodesk.Revit import DB

# access the active document object
doc = Revit.ActiveDBDocument

def show_warning(msg):
    ghenv.Component.AddRuntimeMessage(RML.Warning, msg)

def show_error(msg):
    ghenv.Component.AddRuntimeMessage(RML.Error, msg)

def show_remark(msg):
    ghenv.Component.AddRuntimeMessage(RML.Remark, msg)

Sheets = []

with DB.Transaction(doc, "<Create Sheets>") as t:
    if SheetNames and SheetNumbers:
            for i in range(len(SheetNames)):
                sheet = DB.ViewSheet.Create(doc, TitleBlock.Id)
                sheet.Name = SheetNames[i]
                sheet.SheetNumber = SheetNumbers[i]
        except Exception as txn_err:
        Sheets.append("Please connect all the inputs")

This node gets TitleBlock type, SheetNames and SheetNumbers as a list and creates corresponding sheets with name, number and titleblock family.


Grasshopper groups all transactions into one.

In case you have a complex grasshopper definition with several components starting different transactions would be a little messy to have more than one entry on that list.

How it works now allows the user to UNDO all the changes made by Grasshopper on the last solution pressing just one time CTRL+Z.

Do you need the transaction name shown in the UI for some reason?

I mean I am writing Transaction description in the definition itself. So I am expecting to see it in the UI too. And it would be better to see it so we can differentiate Grasshopper Transactions from each other.

It is not for any specific reason, rather I was expecting it to behave this way :slight_smile:

I see, but the problem then comes when you have lets say 50 components on same Grasshopper file creating Transactions.
If we expose those as separate UNDO steps the UNDO list grows even more crazy than now and makes it harder to UNDO from Revit.

1 Like

You are right. Exposing every transaction will make it even harder. Sorry for taking your time :sweat_smile:. Lately I have been heavily involved in Python in RIR. Started to create my own custom components. All these questions comes from those workflows.

Please keep sharing, it’s always good have to explain why some decisions to think on these again.