Change Revit Link Display Settings and Design Options using API

Change Revit Link Display Settings and Design Options using API

asattar.md
Contributor Contributor
6,123 Views
16 Replies
Message 1 of 17

Change Revit Link Display Settings and Design Options using API

asattar.md
Contributor
Contributor

Hi,

We are developing a plugin that automatically selects the Design options for all the linked models based on an external file (that external file is not even Revit, it could just be a JSON file that lists the design options for linked files).

 

Basically, we'd like to automate the following screens:

  1. Clicking  Edit Visibility/Graphics Override
  2. Navigate to "Revit Links" and for each Link, do the following steps:

     a.  Click "By Host View"

     b.  Select "Custom" (Screenshot 1)

     c.  Navigate to "Design Options"

     d.  For each Design Option Set, select the Design Option from the external file (JSON). (Screenshot 2)

 

We have seen APIs for Categories and Filters, but we weren't able to find an API for Revit Links. We'd be grateful if someone could point us in the right direction.

 

 

Screenshot 1: Selecting Custom for Revit Link Display Settings

 

Screen Shot 2016-05-12 at 11.40.06 AM.png

 

 

Screenshot 2: Selecting Design Option for a Design Option Set.

 

Screen Shot 2016-05-12 at 11.25.36 AM.png

6,124 Views
16 Replies
Replies (16)
Message 2 of 17

jeremytammik
Autodesk
Autodesk

Sorry, off-hand I am not aware of any solution for your problem.

 

All I can do is sit down and research and debug just like you.

 

I wish you the best of luck and hope you find a solution.

 

I would love to hear about it when you do!

 

Thank you!

 

If worst comes to worst, you know that you can simulate every single user action using the Windows API and the .NET Automation library, don't you?

 

The Building Coder published a number of posts on that topic that may help:

 

http://thebuildingcoder.typepad.com/blog/automation

 

I hope this helps.

 

Cheers, Jeremy.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 17

asattar.md
Contributor
Contributor
Thanks for replying to this! We have gone through the API extensively (and we're still exploring it in the hope of finding something). We actually have some crude UI automation using Coded UI tests as a fallback. Thanks for replying again!
0 Likes
Message 4 of 17

Anonymous
Not applicable

Hi jeremy, I am struggling with somewhat the same question. I want to change the presentation of linked files by using the Visibility/graphics dialog to set the linked files on "BY Linked view" and selecting a desired view.

 

Can you put the question to make the Revit Link Display settings available in the API on the Revit wishlist ?

 

Message 5 of 17

Anonymous
Not applicable

Same here...

I'm currently trying to access / filter the selection via the Windows API (no luck yet)

have you gotten anything yet?

Message 6 of 17

Anonymous
Not applicable

Hi there,

 

Were you ever able to make progress controlling Revit Links in the way you proposed? I just posted a similar question here:

 

https://forums.autodesk.com/t5/revit-architecture-forum/rvt-link-display-settings-batch-changes/td-p...

 

Thanks!

 

Spencer

0 Likes
Message 7 of 17

roman.golev
Participant
Participant

Hey guys, it's been 7 years since this issue had been quered. Is there any information if it's going to be implemented in Revit API or not? Feels like nobode really cares abouts that since it had recieved only 4 likes...
 @asattar.md did you manage to succeced with implementation using Windows API?

Kind regards, Roman Golev.

 

Message 8 of 17

asattar.md
Contributor
Contributor

@roman.golev I don't think we were able to. We had to resort to UI automation iirc.

0 Likes
Message 9 of 17

Mustafa.Salaheldin
Collaborator
Collaborator

@jeremytammik is there any update regarding manipulating RVT Links V/G in view template using API?


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 10 of 17

jeremy_tammik
Alumni
Alumni

Hi Mustafa,

    

the best way to find out and also to drive this forward os to check out the corresonding wish list item in the Revit Idea Station and, better still, join the Revit Preview forum and ask the developers there directly.

     

Cheers

   

Jeremy

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 11 of 17

Mustafa.Salaheldin
Collaborator
Collaborator

Yes, I checked the Wishing list 😁

MustafaSalaheldin_0-1742462847459.png

I wished I never went there 😁


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 12 of 17

Mustafa.Salaheldin
Collaborator
Collaborator

I managed to find the solution but I receive a very strange message if I tried to set the display mode to anything other than ByHostView:

MustafaSalaheldin_0-1742510860871.png

I think with a little tweak, it can be possible. I tested this on Revit 2024.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 13 of 17

Mustafa.Salaheldin
Collaborator
Collaborator

@jeremy_tammik The answer is here, it is just not working for some reason. Can you please check with the development team, maybe this needs to be reported as a bug.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

Message 14 of 17

Mustafa.Salaheldin
Collaborator
Collaborator

How can we make use of these two BIP's:

MustafaSalaheldin_0-1742547088218.png

 


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

Message 15 of 17

Mustafa.Salaheldin
Collaborator
Collaborator

@jeremy_tammik any update please?


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

Message 16 of 17

Mustafa.Salaheldin
Collaborator
Collaborator

The good news is now Revit 2026 API allows VG overrides for RVT Links in View Templates.😎

The bad news is it is still not allowing overriding Half tone and Underlay for RVT Link instances in VT. 🤣


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 17 of 17

nizar71
Community Visitor
Community Visitor

Thank you @Mustafa.Salaheldin for the hint,

I've managed to make it working in Revit 2024 using a dictionary to map the views with linked views.

I hope it helps or gives an inspiration.

 

Nizar.

using System;
using System.Linq;
using System.Collections.Generic;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

[Transaction(TransactionMode.Manual)]
public class SetLinkViewOverrides : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        UIApplication uiApp = commandData.Application;
        UIDocument uiDoc = uiApp.ActiveUIDocument;
        Document doc = uiDoc.Document;

        // Define dictionary: { Host View Name → Linked View Name }
        Dictionary<string, string> viewMapping = new Dictionary<string, string>
        {
            { "Site Plan", "Linked Site Plan" },
            { "Second Floor", "Linked Second Floor" },
            { "First Floor", "Linked First Floor" }
            // Add more mappings as needed
        };

        // Collect all Revit link instances
        List<RevitLinkInstance> linkInstances = new FilteredElementCollector(doc)
            .OfClass(typeof(RevitLinkInstance))
            .Cast<RevitLinkInstance>()
            .ToList();

        int successCount = 0;

        using (Transaction trans = new Transaction(doc, "Set Linked Views"))
        {
            trans.Start();

            // Iterate through all views in the document
            foreach (View hostView in new FilteredElementCollector(doc)
                     .OfClass(typeof(View))
                     .Cast<View>()
                     .Where(v => !v.IsTemplate)) // Ignore templates
            {
                // Check if this view has a mapping
                if (!viewMapping.TryGetValue(hostView.Name, out string linkedViewName))
                    continue; // Skip if no linked view is assigned

                foreach (var linkInstance in linkInstances)
                {
                    Document linkDoc = linkInstance.GetLinkDocument();
                    if (linkDoc == null) continue; // Skip unloaded links

                    // Find the specified linked view
                    View linkedView = new FilteredElementCollector(linkDoc)
                        .OfClass(typeof(View))
                        .Cast<View>()
                        .FirstOrDefault(v => !v.IsTemplate && v.Name == linkedViewName);

                    if (linkedView != null)
                    {
                        // Apply "By Linked View" override
                        SetLinkViewOverride(hostView, linkInstance.Id, linkedView.Id);
                        successCount++;
                    }
                }
            }

            trans.Commit();
        }

        TaskDialog.Show("Result", successCount > 0
            ? $"Linked views applied to {successCount} views."
            : "No linked views were set. Check view names in dictionary.");

        return Result.Succeeded;
    }

    /// <summary>
    /// Sets the visibility override of a linked model in a view to "By Linked View".
    /// </summary>
    private void SetLinkViewOverride(View hostView, ElementId linkElementId, ElementId linkedViewId)
    {
        RevitLinkGraphicsSettings settings = new RevitLinkGraphicsSettings
        {
            LinkVisibilityType = LinkVisibility.ByLinkView,
            LinkedViewId = linkedViewId
        };

        hostView.SetLinkOverrides(linkElementId, settings);
    }
}
 
0 Likes