Run script in batches

Hello!
I have too many elements in my script and when i do intersect dynamo just freezes up.
My first list is 3000 complex solids and my second list is 34000 points.
I found by experimenting that running 5-10 solids at a time against the points does not freeze dynamo. But I would need to manually run 300 times.

I tried to make counter in a text file and use periodic running but the calculation of the intersection is not constant and I also have no idea how to stop it because it is unresponsive and just running forever.

Any suggestion?

Please screenshots and files.

I cannot share revit files. I can give you the dynamo so you can look on my nodes. But I think my question is pretty self explanatory. If you have any doubt I can further clarify.
setRoomParam.dyn (174.9 KB)

yes, your question is pretty self “explanatory” but we can’t know, if you made a mistake in your file and we can’t take our time to create a similar case to yours to find a solution.
If you want to get help, you should also help the people here.

I still cannot share the revit file sorry. The dynamo is there.
But then again. We are talking about 3 nodes here, all the rest is running fast if i freeze intersect. One node with 3000 solids, another with a lots of points, and an intersect. I have to run this in batches. This is the question and I don’t know how to do it.
(obviously I know this is only a number now, but I hope you get the point)

I would then recommend you to create a dyn to use via Dynamo player. In Dynamo Player you can use a range of solids and points (Like start-end). And you can run it multiple times, so Dynamo can not crash.

Something like that:

I did use GetItemAtIndex and took a range of numbers from a list but still. I have to run the script 300 times and each time it is taking around 20 sec. So there is no way to automate this?

The problem is: cross-product of Geometry.Intersection. It takes too much time to run all combinations. If we could automate that in Dynamo, Dynamo would wait until all variations done.

1- In other words, avoid solids such as “Solid, Surface” as much as possible to improve performance. These are reproduced on Dynamo, so they slow down your performance considerably.
2- Rotating 3000x34000 =102,000,000 at a time is an astronomical figure. Do you really need to cross lancing all the elements?
3- If the answer is yes, you can go to coding paths such as Python and DesingScript. These will speed you up. It will also allow you to split your list and make a loop. There are hundreds of examples of “looping” within the forum. You can look at it.
4- I’ve reviewed your script. In 2 places, you cross lancing 2 times, and these dots cause your Dynamo to collapse, most importantly, I’ve seen quite repetitiating knots. You can simplify your scenario.

Durmus

Hi I’m cross lacing 3 times but it is not duplicated. I cross intersect: Generic Models then Windows then Curtain Panels in 3 different node. I understand that my figures are big this is where I found having 10 solids from my list against 34000 points is just fine.
I have no idea about coding such things so it is out of my reach for now. So bottom line: it is not possible to solve it only with dynamo, right?

It’s possible, as I said, to stop producing solids and simplify your scenario. For now, it would be really pointless to wait for help without making changes to this scenario.

I have to test if a point is within a solid. Please clarify what do you mean “stop producing solids and simplify your scenario”. I simply cannot substitute the solids with for example bounding boxes as they are not an accurate representation of a shape (donut shape solid vs box shape BB).

Another way to talk about it would be “What is being used to generate the geometry?” and “Is this method producing complex [or resource-intensive] shapes and forms?”

The request to look at the model/script is partly to check syntax, partly to check model state, and partly to check complexity. If you’re truly trying to do 102 million comparisons, you need this to be as lean as possible.

If you are able to use custom packages in your workflow, I have had good success with using Element.IntersectsElement from BimorphNodes. It provides a low-resource method to compare two lists for intersection. It will only tell you IF there is intersection, but you can take the reduced list of confirmed intersections and generate the geometry for that instead.

To address your comment about bounding boxes not being sufficient, consider using them as a pre-screening method: if a collection of points isn’t even within the bounding box, why compare them to the complex form? You might wind up with a significantly reduced points list per complex form.

there are many ways to speed up intersections - ideally Dynamo would do this for you - maybe one day it will.

But you for now, you can try using a spatial data structure, like: GitHub - Dewb/DynamoSpacePartitioning: Dynamo package for spatial queries using tree data structures

But first - I would look at bimorph’s intersection nodes as they should be much faster by intersecting in Revit and not doing the geometry conversions.

2 Likes

Do you need to test each point against each solid, or is it just ‘is the point in any solid’? If the later just Union the solids first. Why are you intersecting the points and the solids in the first place?

1 Like