Batch open files / Batch transfer project information

Hi all,

For hours I am trying to do various scripts and googling other solutions but without success.

I have 15+ models to which i want to batch update/change project information values in a nutshell.

I couldnt solve batch opening of files or updating the values.

Any advice would help.

Marin

Can you do it on one file yet?
If not, start there. If you’re stuck there, post what progress you have made.
If you can do it with one file, what part are you stuck on with many?

It’s hard to give decent advice without better context.

1 Like

Understood.

Below, I tried to open two files, implement random view and then close them.

I am managing to open and close them (save) but cant figure out how to make changes in between?

Marin

1 Like

Try Revit Batch Processor tool. If it doesn’t work than use alternative node in graph.

This is opening the files, but you aren’t interacting with them.

In order to work with background open documents you need to utilize only nodes which have a document input. These are few and far between as background processing isn’t super stable, and can be rather difficult to work with. Look into the orchid package for some additional tools.

Thanks all for the comments. Orchid helped a lot.

I am now able to input parameter into currently open file. I am trying to change it in all open files but it is not working for rest of them.

You need to have a document input into the Element.ByCategory node, as that element will vary project to project.

Orchid may have something for this, or you can look into other means of automation.

  1. A python based route to open a file, get the project info, set the parameter, and close the file.
  2. Journal automation to run the .dyn on multiple rvts via drag and drop.
  3. Revit Batch processor.
  4. A paid add-in.
  5. Etc.

As noted above, background processing with Dynamo is difficult. Not impossible, but difficult. Each and every node which gets or sets information from a Revit model will require that you have a document input.

I resorted to using Python to perform the actions I need in multiple files, this would be the framework that works for me.

import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import System

from System import Array
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

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

paths = IN[0]

for path in paths:
    
    fd = app.OpenDocumentFile(path)
    
    transaction = Autodesk.Revit.DB.Transaction(fd)
    transaction.Start("First Action")
    # Do what you need with the document
    transaction.Commit()
    
    t2 = Autodesk.Revit.DB.Transaction(fd)
    t2.Start("Second Action")
    # Do what you need with the document
    fd.Regenerate()
    t2.Commit()

    fd.Close(True)

OUT = paths

I would say as Jacob, BVN (RVT exporter) and other tools is better than BGopen with nodes in my opinion…I love to use Birdtool very similar to BVN tool just without the option to batch run with windowstaskscheduler as BVN support…but think Birtool is a little bit faster as it actuelly are in a open document when run.where BVN has to open close the document from scratch…but both great tool and great option to BGopen…PS Birdtool can run on BIM360 as well