How to make a bulk-task to 1 by 1 task in dynamo by Transaktion?

Hello Dynos,

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()

grafik


KR
Andreas

image

This bit… Check your indents.

I find it really annoying using Dynamo Python node. I get this often.
Even if it looks fine it sometimes complains.

I delete all the indents then do them again. Tedious but it works.

I prefer to use Tab for my indents.

@Alien ,

i think it is more than that… i am not shure how to divide the task :confused:

Yes, it will be…
But fix 1 bug at a time.

When you have fixed the indent bug you’ll get a new error which will give you a better clue. :slight_smile:

1 Like

Try this instead:

  1. select all the subsequent row with a matching indent.
  2. Hold down shift and hit tab until everything is as far left as it can go, keeping count of the number of times you press tab.
  3. Release shift and press tab the same number of times.
  4. Move to the next indentation level.

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!

Have not had any issues with this myself; perhaps there’s a conflict with the AvalonEdit reference in your Dynamo environment?

Say who what now?

What is this and how can I fix?

I’m in R21 and Dyno 2.6.1

BTW - it does work sometimes. Just not all the time.
Wasn’t working yesterday, has just worked now.

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. :slight_smile:

2 Likes

@Alien , @jacob.small ,

I solved it finaly

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

KR

Andreas

4 Likes