Loop nodes

Hello,
I have a group of nodes that need to be run with a view and 3 lists.

Task #1 is to create a bounding box list.
Task #2 is to apply the list of crops to the given 3D view
Task #3 is to export the given 3D view as an image, once for each crop.

In the screen shot you can see the data I feed to the group.

Currently the images exported are all the same, they show the last crop only.

I tried lacing longest, on some of those nodes, but no luck.

Any suggestion / improvement?

Sometime ago I solved a similar issue using a custom node, which worked in executing the nodes through the lists of data, but I wish to avoid using custom nodes now.

Thank you

I don’t know if this would work. But i’d try to chop the lists.

List chop +1 on the two lines entering the view.export as image

If you look at the watch node all the boxes are the same

Have a look at what is coming out of your bounding box node. Get that right before moving on.

Well, no, the boxes are different, what is the same is the 3D view.

Is only the crop box that changes.

So you’re only feeding in one view?
You can’t crop a view 5 different ways.

Maybe I misunderstand what you’re trying to do here?

1 Like

Let’s simplify:
you have one view, a list of N crop boxes, and a list of N filenames.

How do I save one image for each scope box?

Ah…
Dynamo runs all the way through and stops… So with some stuff you can’t get it to do X… then update to Y.

Unless… you set it to periodic… and step through each run.

So it runs for the first box… then runs for the second etc.

I’m not sure if exporting images would allow you to step through the process without using periodic… But the periodic method would work.

IF you can alter the scope box… then take a picture… then alter the scope box and take a new picture… you’d have to do that in a python loop I’d guess… or build one bunch of nodes per run.

what’s “periodic”?

You can set your run to automatic, manual or periodic.

If you added a counter to step through the indexes depending on time you could step though each bounding box.

You could try repeating the nodes so you set box at index zero, then take picture, set box at index 1 take picture… But I don’t think that’ll work.

Periodic lets dynamo run… then run again, then run again…
So it’s actually several runs, one for each index.

I’d just have it create copies of the 3D view for each crop box.

1 Like

Don’t go with periodic run here. It’s too unpredictable for what you’re after as execution times in Revit vary far too much.

Instead:

  1. First duplicate the view once for each bounding box.
  2. Set the bounding box to the view.
  3. Export the views.
  4. Delete the views.

You might need to put a Transaction.End and a Transaction.Start node on canvas at a few points.

That’s no where near as much fun :smiley:

Also… if you’re only doing 5 views then periodic is fine… You can get it to run every 5 seconds easily. Even the worst computer can manage that surely!

Image export is not a consistently timed action… If you’re doing simple wireframes, sure. Rastering a perspective at a high resolution…

1 Like

True…

I just really enjoy periodic scripts though. :slight_smile:

1 Like

Hi Jacob, years ago this was working just fine, as a custom node:

Few weeks ago I tried it again, and it wasn’t working anymore.

I get the correct number of images, but they all represent the last frame / crop box.

This is not feasible since there could be thousands of frames, and Revit will crash when trying to create those views.

That is why, in the original script, I had to perform the export on one view at a time… while deleting the old view after export.

yes, one 3D view, and different crop boxes.

Again, the sequence would be:

  • apply a crop box
  • export image
  • repeat with next crop box.

That’s annoying. I’ve never had issues creating hundreds/thousands of views at once, even 3Ds. Is it feasible to break it down into chunks (e.g. max 300 views or something) where it won’t crash? Otherwise I think you’re stuck with having to use either custom node(s) or Python…

Ok everyone, it works.

Not sure what happened and why it stopped working when I dig out this script from 2019, few weeks ago.

Here is the custom node:

The one I sent to Jacob replaced the “View3D.SetSectionVBox” node with the OOTB “View.CropBox” which is just the view 2D crop, NOT the Section Box. That was my mistake.

1 Like