i do very simple excercise put a string to comments. The task works well, but i want, that each filling is a task(strg+z)…
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from System.Collections.Generic import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
elements = UnwrapElement(IN[0])
result = []
for i in elements:
for j in i.Parameters:
p = i.LookupParameter("Kommentare")
TransactionManager.Instance.EnsureInTransaction(doc)
p.Set("X")
TransactionManager.Instance.TransactionTaskDone()
so all wall in one task, but how can i do it one by one ?
like this:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from System.Collections.Generic import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
elements = UnwrapElement(IN[0])
result = []
for i in elements:
for j in i.Parameters:
p = i.LookupParameter("Kommentare")
tx = Transaction(doc, "Kommentar")
tx.Start()
p.Set("X")
tx.Commit()
I find shift and tab works perfectly in Visual Studio and also in IDLE Python… But it’s really flaky in the Python nodes in Dynamo - sometimes shift and tab even moves the lines the wrong way!
I may have the wrong name, but I believe that the teat editor which the Python node uses is AvalonEdit. In theory a dependency conflict where another tool loads AvalonEdit 1.X before Dynamo loads AvalonEdit 1.Y could cause inconsistent behavior. But if it’s not broken now, don’t sweat it.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from System.Collections.Generic import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
elements = UnwrapElement(IN[0])
result = []
x = 1
for i in elements:
for j in i.Parameters:
name = "Kommentar " + str(x)
t = Transaction(doc, name)
t.Start()
p = i.LookupParameter("Kommentare")
p.Set("X")
t.Commit()
x = x+1
OUT = "Done"
these are native Revit transactions instead of Dynamo transactions