Search code examples
autodesk-forgerevit-apiautodesk-bim360

Is it possible to load new Cloud (BIM 360) links in a Revit model either through the Revit API or FORGE API?


I have a two-part WPF App and Revit Addin that runs a series of routines to create and activate a new BIM 360 project via the FORGE BIM 360 API, launches Revit and creates and sets up a collection of Revit models from a "seed" Revit model. The primary requirement is to have zero user interaction in this process: to be fully automated.

Given that background, I am having trouble linking the newly saved BIM 360 models to one-another. I have the option to do this either in the Revit Addin with Revit API hooks (preferred) or through the manager WPF App with FORGE API REST calls after the models are created.

Is either one possible?

I have successfully linked with the cached local models as described here and here. However, this does not meet the requirement fully, since when any other user (besides the automation machine user) opens the model the links are Not Found.

Screenshot of links Not Found.

Current "sort-of-working" code:

var wId = GetWorksetId(doc, w);
if (wId != null)
{
    string localPath = settings.CloudModels.Where(x => x.ModelName == _linkModelNames[i]).Select(x => x.LocalFilePath).First();
    ModelPath path = ModelPathUtils.ConvertUserVisiblePathToModelPath(localPath);

    using (var options = new RevitLinkOptions(true))
    {
        using (var t = new Transaction(doc, w))
        {
            t.Start();
            doc.GetWorksetTable().SetActiveWorksetId(wId);

            using (var result = RevitLinkType.Create(doc, path, options))
            {
                _ = RevitLinkInstance.Create(doc, result.ElementId);
            }

            t.Commit();
            linkPlaced++;
        }
    }
}

I was able to get the correct ModelPath via the Revit API thanks to this helpful tip. I can save this value in my Addin, close the model, and access the property later after opening a different model (saved in the CloudModels class referenced in the linq statement in the code snippet above). Unfortunately for me RevitLinkType.Create() that takes a ModelPath does not accept the cloud path, so I may have hit another dead end. Unless it is possible with an ExternalResourceReference. Has anyone tried this option? If so, how do you assemble a Revit ExternalResourceReference? I am not familiar with this process, and looking over this course from AU 2017, I don't see that it necessarily applies to BIM 360 cloud models. A BIM 360 cloud example would be very helpful if this is possible.

Alternate strategy: I do not see any reference to loading links in the FORGE Data Management API or other FORGE APIs. If I have somehow missed it, please share a link.

Any help would be very much appreciated!!

EDIT: I have since found these two (1) (2) similar questions that, at least for my purposes, were not answered satisfactorily. Any updates I should be aware of?


Solution

  • As of now (Jan 2020), unfortunately, we do not have a Link API for cloud models. It is on the roadmap.