“Code here” meant a change I do in the document. Code down below is an example:
import clr
clr.AddReference('System.Core')
clr.AddReference('RhinoInside.Revit')
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
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:
t.Start()
if SheetNames and SheetNumbers:
try:
for i in range(len(SheetNames)):
sheet = DB.ViewSheet.Create(doc, TitleBlock.Id)
sheet.Name = SheetNames[i]
sheet.SheetNumber = SheetNumbers[i]
Sheets.append(sheet)
t.Commit()
except Exception as txn_err:
show_error(str(txn_err))
t.RollBack()
else:
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.
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
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.
You are right. Exposing every transaction will make it even harder. Sorry for taking your time . Lately I have been heavily involved in Python in RIR. Started to create my own custom components. All these questions comes from those workflows.