Message 1 of 2
SetLinkOverrides is not working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been working on a tool to override Revit Links. I use a new method, SetLinkOverrides (or Remove), but after running it, nothing happened. What went wrong? How can I change the visibility of a linked document? I use Revit 2024. Maybe this method is not working?
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using RevitExtension.Elements;
using System.Linq;
namespace BuiltExporter.ExternalCommands
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
internal class TestCommandExternalCommand : ExternalCommand
{
public override void Execute()
{
UIDocument uidoc = new UIDocument(App.ActiveUIDocument.Document);
// Get the active view
View activeView = uidoc.ActiveView;
//Get links
FilteredElementCollector elements = new FilteredElementCollector(activeView.Document);
var links = elements.OfClass(typeof(RevitLinkType)).ToList();
var doc = activeView.Document;
using (var Transaction = new Transaction(doc, "Remove Link Overrides"))
{
Transaction.Start("Remove Link Overrides");
foreach (var link in links)
{
RevitLinkGraphicsSettings settings = new RevitLinkGraphicsSettings()
{
LinkVisibilityType = LinkVisibility.ByHostView,
};
activeView.RemoveLinkOverrides(link.Id);
// view3D.SetLinkOverrides(link.Id, settings);
}
Transaction.Commit();
}
}
}
}
My goal is
or