Exporting images from multiple Revit files at once

I made a simple script that exports images from Revit families and applied it to an entire family library using RBP. Quickly realised this approach would take a really long time with RBP having to open and exit Revit for each family, and we have many.

Instead I tried using Rhythms open and close application nodes which is a lot faster and does output images as I would like. However all of the images, though named correctly, contains the same view from whichever project I have open when I run the script.

The IF statement makes sure the script doesn’t stop when opening families without 3D representation. Is there a way to pull views from the opened project files instead of the current one?

Hey,

The Document.Default3dView node has the option of a document input? I think? Can you feed that in?

Hope that helps,

Mark

Tried that, gives me a null output which in turn shifts to the true input of the if node, which again uses the current document.

If there is a package out there with nodes that can pull views from documents other than the current one that would solve it. Perhaps it’s just not how Dynamo works.

Depending on whether the file (which you had open when you opened Dynamo) is a project or family will affect how Dynamo reads the files you’re trying to open…

Did you try making a(ny) new family and launching Dynamo from there, then running it?

I did try it from within a project file as well as a family, the results are exactly the same.

Ok, I would query the default 3D view node with Clockwork’s github, it should be working…

If you dig inside it you can copy it all out into your main Dyn and see what’s breaking? I can’t see anything obvious…

Just another small thing, there are image export nodes in archilab… though you’ll still need the correct views to feed it.

Hope that helps,

Mark

I found a node from the Crumple package that outputs documents that works with the Document.Default3DView node.
image
Next issue is that View.ExportAsImage seems to break when the input is a view not present in the active document.

1 Like

Can you generate a new 3D view? or would you prefer to filter those ones out?

Doesn’t really matter at this stage, new views works!

1 Like

Pretty sure you’ll need to code up something that takes a document and a view to export the image. Shouldn’t be too hard in Python.

This is the command to actually do the export - note it is in the doc class so the different documents you input will have this method called on them. ExportImage Method

That method takes an image export options argument, so you’ll need to build one of those first: ImageExportOptions Constructor

Once you create that, you can set the file path you want to save to (perhaps deriving this from the document’s name and path?): FilePath Property

And then set the view(s) to export for that document: SetViewsAndSheets Method

You may also want to look into other properties you can set, shown here: ImageExportOptions Properties

2 Likes

Unfortunately I don’t know Python at all, but maybe this is a good excuse to learn. Thank you for the head start!

If I manage to write the entire script in Python I’ll also try running it directly from RBP since Python scripts can be run in the same Revit instance, should speed things up.

If going full python, Dynamo’s Python node can open the file, get the data, and return the results for a full directory - you just move the opening of the documents to the Python node as well - no need to go to RBP or other tools as a result.

1 Like

Honestly, the background document stuff is very hard to manage in Dynamo itself.

I would end up making a graph that works on the current file. Then, I would allow this tool to “batch” that workflow. Dynamo Multiplayer

I did a video overview of this here:

3 Likes

I did a test with 100 .rfa files, took 48 seconds/file to process. A lot faster than the 3 min/file RBP took. My approx 1200 files would take around 16 hours to complete. Not too bad…

2 Likes