Batch Exporting to FBX

I’m trying to come up with a script that looks at a directory for Revit models (approx. 40 files) & converts a specific 3D view in those files into a FBX file. Each of the Revit files are set up as Central models, and the view I’m looking to convert has a View Template assigned to it. Some of those ~40 files are linked to each other (Reference type is Overlay), but I want the final FBX to only be what has been modeled in the file. I have 1 “master” file that has every Revit model Linked.

The topic listed below is the closest I’ve come to being able to achieve this, but I’d prefer to not have to create 3D views that only displays 1 Link & then have to call out each of those Views manually.

Is the only 3d view in each model that uses the template the one you’d want to export?

Yep, just that one. The view template is controlling things like phasing, what worksets are visible, etc.

So… because this works on external documents I wouldn’t recommend using a node approach by itself. I’d look into the following:

  1. Use a node based graph in conjunction with a batch processing tool such as “Dynamo Multiplayer” from bird tools (I believe this is free, so why not?).
  2. Use a node based graph in conjunction with journal automation to run Graph X on models 0…n (this method may be ideal here as it can be triggered automatically from outside of Revit via .bat file).
  3. Use a single Python node to loop over a list of files which would: open a detached copy of the model with linked worksets closed (so links aren’t an issue), get the 3D view using the template, and export to FBX.

Personally I have used a combination of 2 and 3 for scheduled DWG and NWC exports before; FBX wouldn’t be too much of a stretch. It will take some work on your end though. Can you post what you’ve tried so far?

Right off the bat I wouldn’t be able to do the first one (at least for some time) since I’m unable to install software on my machine & even free software needs to go through an approval process.

Number 3 in your list sounds the most promising, but this is what I’ve pulled together so far. Some of it comes from the example script provided with Datasmith but I’ve tweaked it to meet my needs.

I’ve alternated between using the Export to FBX node from Data-Shapes (ver 2022…2.103) & the IO.ExportAsFBX from WombatDynamo (ver 2.3.5), but neither end up exporting out a FBX file. When ran in Dynamo I get no errors with the above graph as shown.

When I switch it to use IO.ExportAsFBX I get the error about it asking for a specific view. I suspect the error is a result of the Filtering/List.

This is all for the ACTIVE Revit file though, right?

The issue is that the Python node you’re using to get the 3D views is parsing out a view, but we aren’t maintaining an open Revit Document to get to the data. Right now you’re sending element 181960 to the “export to FBX” node, and not providing the node with the document in question; as a result it’s going looking for element 181960 in the active document, which is almost assuredly not a 3D view, and quite likely not something which exists or can be selected in any way. As a result, you’re getting failures on export (in the form of ‘null’ or the error noted before).

While it is possible to pass along a document object (seemingly more and more so by the day with some recent forum posts), it’s almost always going to be faster to

  1. open the file
  2. get the views
  3. export the views to FBX,
  4. close the file

For best results I find that all four of those steps should be done in one loop; either in a Python node or a custom node. Passing the document otherwise the files have to stay open in memory, eating up resources).

Give the Python loop a shot and I’ll give some direction as best I can, or share a sample you can edit should I have time later this week.