I am looking how to Set Revit Links Display Settings as Revit Link View with Dynamo, I mean change from By Host View to By Linked View and select which view of the link afterwards. Hopefully the answer is not Revit API not available blabla
Yes you have right here i guess
It’s been requested for a long time now, but yes I think @sovitek is right here in my experience. There are some workarounds that achieved using apply template properties and storing linked view graphic sets as templates, then unlocking this section in applied templates, but it’s a workaround of course and wont suit all scenarios.
Here’s Jeremy commenting on it in 2016. But we can copy sheets now I guess… woo.
Yes thats great, have just wait for it the last 12 years thx Autodesk
Personally I’m just dreading all the views with copy names in models. It’s a great feature for architects, and a scary one for those who do the cleanup.
havent tried 2022 yet…hope its build the way so its possible to control duplicates naming so we dont have to manuel rename them again
Is this from chatGPT? Noting this thread is old as well.
Have sent you a dm in case this isn’t the case, but please refrain from reviving old topics and just providing GPT summaries if this is the case here.
Not the first instance of this posting we’ve seen now. ChatGPT bots being launched at forums? I wonder…
@GavinCrump
post deleted
I don’t know a direct dynamo solution for that yet and i don’t understand the last comments which are talking about something else.
What I did is to copy views and view templates from revit links with dynamo and apply them to the current revit file opened. And trying to copy the annotative elements as well…but not worth the efforts. Forgotten task…too much for no satisfaction
The reply was deleted, but it was a big list of unuseful tips that looked to be made by chatgpt.
Revit API for this is now available in revit 2024, but not older versions.
Hi Gavin,
Is it a way to show how it would work on Dynamo? I am working AV industry, and I use Revit links for my elevations. I have a template where I place screens, video bars, sockets and data (detail item only), containment (detail item only), and plywood (detail item only). All dimensions are attached to objects, and they also have predefined views. This template is automated. Let’s say I have five types of meeting rooms, so I create five project files from the elevation template. When meeting rooms project files (in this example five) I linked them to the main model.
Main model.
I already have set up Revit links display settings for views. I don’t need to do anything in the main model with section views.
In GA plans, I copy Revit links and move around the plan. The problem comes when I duplicate Revit links it adds to all views which affect sheets because it starts to show views which are not supposed to be in.
Is it a way of using Dynamo script to untick duplicate Revit links from section plans? Please see the image below.
Kind regards
Robertas
Hello Gavin
Could u tell me how to deal with this point in Revit 2024 API
Best Regards
The article here summarizes the changes:
https://thebuildingcoder.typepad.com/blog/2023/04/whats-new-in-the-revit-2024-api.html#4.2.14
Its just a handful of methods so if you know Revit API it should hopefully make sense.
Ok thank you
GBT struggled but Claude got it pretty fast. Is it good code, I dono. But works for single and even listed inputs if anyone needs. I couldn’t find a solution anywhere else encase I’ve missed it.
Seems to work with multiple links in project but only tested with 2
# Enable Python support and load dependencies
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from typing import Union, List
from System.Collections.Generic import List as CSList
# Input ports for Dynamo
host_view_input = IN[0] # Can be single view or list of views
linked_view_input = IN[1] # Can be single view or list of views
def unwrap_element(element):
"""
Unwraps a Dynamo-wrapped element or returns the element if already unwrapped.
"""
if hasattr(element, "InternalElement"):
return element.InternalElement
return element
def process_input(input_item):
"""
Process input items which could be single items or lists.
Unwraps elements and converts to proper format.
"""
if isinstance(input_item, list):
return [unwrap_element(item) for item in input_item]
return unwrap_element(input_item)
def find_specific_link_type(doc, linked_view):
"""
Find the RevitLinkType that corresponds to the document containing the linked view
"""
linked_doc = linked_view.Document
linked_doc_title = linked_doc.Title
# Get all link instances
collector = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
for link_instance in collector:
try:
# Get the document of this link instance
instance_doc = link_instance.GetLinkDocument()
if instance_doc and instance_doc.Title == linked_doc_title:
# Found the matching link, return its type ID
return link_instance.GetTypeId()
except:
continue
return None
def set_linked_view(doc: Document,
host_view: Union[View, List[View]],
linked_view: Union[View, List[View]]) -> None:
"""
Sets the view display settings for Revit links to show by linked view.
Only sets the override for the specific link that contains the linked view.
Args:
doc: Active Revit document
host_view: Single View or list of Views to modify
linked_view: Single View or list of Views to link to
"""
# Convert single values to lists for consistent processing
host_views = [host_view] if not isinstance(host_view, list) else host_view
linked_views = [linked_view] if not isinstance(linked_view, list) else linked_view
# Validate input lengths match
if len(host_views) != len(linked_views):
raise ValueError("Number of host views must match number of linked views")
# Start transaction
TransactionManager.Instance.EnsureInTransaction(doc)
try:
for host, linked in zip(host_views, linked_views):
# Find the corresponding RevitLinkType for this specific linked view
link_type_id = find_specific_link_type(doc, linked)
if not link_type_id:
raise Exception(f"Could not find the specific link type for view {linked.Name} from document {linked.Document.Title}")
# Debug output
print(f"Host View: {host.Name}")
print(f"Linked View: {linked.Name}")
print(f"Linked Document: {linked.Document.Title}")
print(f"Link Type ID: {link_type_id}")
# Create new graphics settings with the linked view
graphics_settings = RevitLinkGraphicsSettings()
graphics_settings.LinkedViewId = linked.Id
graphics_settings.LinkVisibilityType = 1 # 1 corresponds to ByLinkedView
# Apply the settings to the host view for this specific link only
host.SetLinkOverrides(link_type_id, graphics_settings)
except Exception as e:
TransactionManager.Instance.ForceCloseTransaction()
raise Exception(f"Error setting linked view: {str(e)}")
# Get the current document
doc = DocumentManager.Instance.CurrentDBDocument
# Process inputs
host_views = process_input(host_view_input)
linked_views = process_input(linked_view_input)
try:
# Execute the main function
set_linked_view(doc, host_views, linked_views)
TransactionManager.Instance.TransactionTaskDone()
# Set output
OUT = "Successfully set linked view(s)"
except Exception as e:
TransactionManager.Instance.ForceCloseTransaction()
OUT = str(e)