Force Dynamo to do divide huge task into subprocesses?

Hypothetically let’s say I need to insert/modify a huge number of items in a Revit model, would it be possible to automatical process/insert/modify the data in chunks/subprocesses.

Example - task, insert 10.000 windows:

  • subprocess 1, insert 1.000 windows -> done -> save
  • subprocess 2, insert another 1.000 windows -> done -> save
  • subprocess 10, insert the final 1.000 windows -> done -> save

Hypothetically yes…using python i think using While count…then if count reaches a certain number then save then continues on…but i dont know how to insert/modify using python…maybe some of the python master can help…

List.Chop and then List.GetItemAtIndex with a number slider capped at your upper limit of the groups of 1000 windows. Would have to close Dynamo between runs or use player in this instance though.

Maybe, but the API should have the “move objects to Revit before continuing the script” feature. That’s would be a solution. Still, need the name of this feature, waiting for a Revit API expert :wink:

Yeah, but I don’t want to “run dynamo” for each “subprocess”. I only want to press run once. :slight_smile: … and then go to a meeting, lunch or have a long break :wink: hehe

Splitting the list or any other fiction before placing the windows will require additional work time not less, as te CPU still has to deal with the total sum, so if you want a ‘one run graph’ leave it as is and invest in a Dunkin Donuts loyalty card. :stuck_out_tongue:

Maybe the Donkin Donut solution is not such a bad idea. If it crashes, I’ll have an excuse to go for the second DD visit :wink: #dontTrustRevit

I would laugh if I hadn’t been there before on a larger job and deadline.

Another thought: make the script run faster via codeblocks and Python scripting. Plenty of discussion on that elsewhere around for reference.

Thanks but, I have already optimized the script w. code blocks, (iron)pythonic code, etc. But you’re right there is always room for more optimization.

Maybe the “subprocess feature” doesn’t exist, but still if it does it would be a nice feature to know about/have.

Yeah in order to have the subprocess really gain any speed I believe that Dynamo would need to support multi-core processing, which I would love to see, but we would need it in Revit first.

How big is your dataset here? 3,000 windows?

Asking in general, I have multiple use cases and models. It depend on the model and task. Creating N openings in a construction model based on architecture firms model could be one of many tasks. If the building has N openings they need to be moved in some way, I prefer to press one button.

Hello Thomas!

I’ve done something like that, without the automatic save. Look if you can take something from it: My inputs are quite obvious, only “Locations” are actually points (a flatten list of points)

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application


# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)


HostingWall = UnwrapElement(IN[0])
lvl = UnwrapElement(IN[1])
WindowType = IN[2]
Locations = IN[3]
InputPoints = []


collector = FilteredElementCollector(doc).OfClass(FamilySymbol).ToElements()

WindowSymbol = UnwrapElement(WindowType)

#ACTIVATION

WindowSymActivated = WindowSymbol.Activate()
doc.Regenerate()


for i in Locations:
	a = i.ToRevitType()
	InputPoints.append(a)

#Starting Values 
step = 4
counter = []
startCount = 0
endCount = (len(InputPoints)/step)
lstAus = []
windowsLst = []

TransactionManager.Instance.EnsureInTransaction(doc)

for x in range(0, step):

	TransactionManager.Instance.EnsureInTransaction(doc)
	c = 0
	ChoppedList  = InputPoints[startCount: endCount ]
	
	for each in (ChoppedList):
		c += 1
		counter.append(c)
		j = doc.Create.NewFamilyInstance(each, WindowSymbol, HostingWall, lvl, Autodesk.Revit.DB.Structure.StructuralType.NonStructural)
		windowsLst.append(j)
	startCount = endCount
	endCount += c
	
TransactionManager.Instance.TransactionTaskDone()	


OUT = windowsLst

Here is the Dynamo Graph, only used to grab a face from a wall, then use that face to create a list of points:

2 Likes

Not quite what I’m looking for but still useful in other contexts. Thank you for sharing! :slight_smile: