In dynamo / python, how to open revit file from autodesk docs? Seems like if it is from autodesk docs, it doesn’t really work, keep on freezing.
doc = app.OpenDocumentFile(file_path)
Thanks!
In dynamo / python, how to open revit file from autodesk docs? Seems like if it is from autodesk docs, it doesn’t really work, keep on freezing.
doc = app.OpenDocumentFile(file_path)
Thanks!
Autodesk docs can host cloud-workshared models (cloud collaboration for Revit) and drag-and-drop models that are not cloud workshared.
For cloud-workshared models you need the projectGuid and modelGuid of the model to build the modelPath. So instead of the file_path, build a modelPath per the following link:
For non cloud-workshared models, you need Desktop Connector and you should just pass the filePath to the Autodesk Docs drive.
How did you build the file_path variable?
Aha, thanks for your response, @hamid-dpr! It is more complicated than I anticipated.
I am trying to access a cloud-workshared models from dynamo. For the filepath I put the filepath of file from the Autodesk Docs drive:
e.g: “C:\Users\ [ username ] \DC\ACCDocs\ [ project ] \Project Files\test.rvt”
Okay this sent me down the rabbit hole but I hope it helps. Lets cover a few items first.
(1) The method that you are using is for opening the model in background and it will not be opened in the UI. I assume that is your intent.
(2) Since it is a cloudworkshared model and you were trying to open it using the desktop connector, you would have opened the “published” version of the model and not a live synchronizable model. So you have to explicate your goals (do you want to use the published content? or the live content? do you want to change/synchronize the model?). I assume you want to change/synchronize the model, so lets focus on opening the live cloudworkshared model.
(3) You need the projectGuid and modelGuid of the cloudworkshared model. You have to either grab these datapoints using the APS platform APIs (get the project, folder, items, and item data of the revit file: https://aps.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-items-item_id-GET/), or you can open the model in Revit UI and use the Revit lookup add-in to get them (GitHub - jeremytammik/RevitLookup: Interactive Revit RFA and RVT project database exploration tool to view and navigate BIM element parameters, properties and relationships.). In Revit lookup, go to Snoop Active Document > GetCloudModelPath, like the snapshot below.
(3) now that you have the modelGuid and projectGuid you need something like this in Dynamo but know your Revit version upfront, adjust your region and openOptions (e.g., worksets, etc) per your requirement, and wait for the file to download. this is the minimal version:
#your regular dynamo python Revit API imports before this line
from System import Guid
projectGuid = Guid("a1486eae-e444-44e1-bd23-e27a59aa4548")
modelGuid = Guid("1cdd691b-323a-4c43-a6ec-92f025039")
modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(ModelPathUtils.CloudRegionUS,projectGuid,modelGuid)
openOptions = OpenOptions()
newDoc = app.OpenDocumentFile(modelPath,openOptions)
However, in Dynamo, opening a cloud model in background apparently does not get rid of the Open File popup even after the model being fully loaded, and it will lock Revit UI. Not sure if this is a bug, or showed in my setup of Revit 2023, but I do not have any solution for that problem.
(4) In a Revit macro, the same approach works fine and that pop-up goes away when the model is loaded.
public void openCloudFile()
{
Autodesk.Revit.ApplicationServices.Application app = this.Application;
Guid projectGuid = new Guid("yourProjectGuid");
Guid modelGuid = new Guid("yourModelGuid");
ModelPath modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(ModelPathUtils.CloudRegionUS,projectGuid,modelGuid);
OpenOptions openOptions = new OpenOptions();
Document newDoc = app.OpenDocumentFile(modelPath,openOptions);
}
(5) Close the file after your workflow using the newDoc.Close() method. Otherwise, it will remain open in the background and potentially cause other problems.
I recommend pulling the model GUID and project GUID via APS (Autodesk Platform Services, formerly known as Forge).
For use of the APS APIs calls you can review the tutorials and other documentation here: https://aps.autodesk.com/en/docs/data/v2/tutorials/download-file/
I believe that the combination of “download file” and “publish a Revit model” should get you what you are after. Going another route will require manually finding the model GUID for each new cloud worksharing model.
Thank you @hamid-dpr for your thorough explanation and guidance of how to get it set up!
Yes, I am trying to open the model in the background. I am trying to create a workflow for the user to select another revit file, copy and paste contents from the other revit file to the current revit file.
Seems like the Revit lookup tool can be a good starting point, and the APS will ultimately be the end goal! Thanks again for your help, much appreciated. Such a warm community
Thanks @jacob.small Thank you! I agree with your comments. I will look up the APS API documentation.
Let us know what solutions you find because i asked the same years ago in this forum and i forgot about absolutely
Hmm, seems like it is stuck on opening. Is there a reason why it might happen? Thank you all in advance!
Might have rate limited yourself, or you are lacking space on your C drive, or your personal accelerator is full, or you just have a lot of files. The journal for Revit should provide some insight.
Thank you!
Alternatively, you can also use Bird Tools Plugin from Autodesk App Store to run Dynamo Script/s to multiple models RFA/ RVT also from Cloud, like in the image below. I would say, it works quite well. It also has the option to SYNC after the operation. One problem that I face sometimes, is that, if there’s a warning while opening the model for which you have to click OK manually, then it waits for your mouse click to proceed further and the further automation process is halted, and it only continues when you click OK. It’s also a free plugin. Otherwise, I find it useful for batch operations to be done for Workshared Models.
@kuomaje Did you get to solve this issue ? I am struck here too.