Using multiple files at once

I have a situation where I am trying to copy geometry from one .rvt file to another as well as manipulate geometry in both files simultaneously. It is my understanding that this cannot be done dynamo, correct?

Would it be possible to do this in python or c#?

Essentially, I have a container/documenting file of dozens of apartment units which I want to copy and paste into individual files to link into a core/shell building. This method is preferred to groups for our team. This process happens a few times a week as the units change and I’m trying to automate the process.

From what I can gather, a single session of dynamo can really only effectively work in one file at a time. I know it’s possible to open a second file in the background, but this process only works sporadically and doesn’t seem stable.

Generally background files should only be held temporarily and always closed by the time a script finishes. You can point to the current as well as other documents using Dynamo or pyRevit, and some methods work between them such as copying objects.

Dynamo works with transactions from the Revit API which in most cases expect to reference one document at once, although I believe you can technically span two documents in one transaction depending on what you are trying to do.

We do this all the time with no need for code(?)
We have standard unit types as RVT files in our library. These have one level. The level style is without a level head - just the line. The level is set to 0" not 100’ as in the project. We use the same project point for all units for fast switching of unit types. We start a design with these typical units.

We’ll build a unit in the base model if it is unique, or it is a new design - let’s say a corner unit. We’ll grab all the elements for the unit. Group them. Then turn the group into a link. Done. Later we might take that new linked file, clean it up and add it to our library.

You can do the same with your container document. Just open it up. Group. Link. Done.

This is the way we started…just using the ‘save group as’ feature in the project browser. Unfortunately, I don’t think this will work with BIM360/ACC.

BIM 360 is pita for lots of prototype projects. It doesn’t allow for sharing of resources across projects.
Would be interested in hearing your strategy.

Copying elements from one document to another is straightforward. Manipulating both models at the same time - more difficult. Python or C# is going to be easier here. They allow background file opening and manipulation. So, I’d skip Dynamo from what you’ve set out so far.

The copying of elements from one file to another is just a few lines of code with the API.

Well, currently this is our workflow. Assume we have 20 units in our central documentation file.

1). Copy Geometiry (in a 3D view) of unit ‘1’.
2). Open up the separate revit file (from the cloud) that just has unit ‘1’ geometry.
3). Erase everything except for the level in the unit ‘1’ file.
4). Purge everything in the unit ‘1’ file.
5). Paste the geometry ‘aligned to level’.
6). Save and-or load into the core/shell model as links.

This allows us to document all of our units in one file and freely move the unit links in the core/shell model. This method works best because we find ourselves well into DD’s or even CD’s before the unit locations stop changing due to owner requests. When they were documented in the same model this would destroy our unit documentation.

I don’t know python or C#, but this may be a good reason to start learning as opening up these files and copy/pasting the geometry into each one takes a long time. It’s worth it for us, but always looking to cut back on repetitive tasks.

That said, I’m still unsure how I would get python or C# to automatically open these files from the cloud. Opening them from the local network is one thing—but does the API allow you to access cloud-based files?

Yes. The API allows you to open cloud based models.

Great. Now that I know I need to learn python a little more in-depth, what is the best resource for that? Are there forums similar to this one for Revit and Python? I know Gavin’s done some good youtube videos but that’s about the limit of my resources.

Plenty of good Pythion on this web site to start learning. Below are what I’d consider the top 3 for learning Revit API. Plenary of good resources for just non-Revit Python available. Most of the code is in C#, but you’ll learn how to translate that. All languages have similarities. VBS and CS languages will be more tightly bound to teh API. Python is tied to IronPython or CPython and there are some gaps where Python can be frustrating.

I’m a big fan of pyRevit - especially for offices with limited IT backup. Writing plug-in’s for Revit can be fun, but time consuming. pyRevit makes deployment and maintenance a snap. It also allows you to run, Dyanamo, Python scripts, C#, scripts, VB scripts. Even works with DLL’s if you want.

I personally use Visual Studio Code for editing. It is the right fit for what I do. Visual Studio is great for ass-ins, but overkill, for smaller projects.

Revit API
pyRevit
The Building Coder