Turn on/off Link with the same Script

Hello everyone!

I’m trying to turn on and turn off a Revit Link with a Dynamo Script. I’m using 2 packages: GeniusLoci and Rhythm, the script function perfectly, but I have to change manually the Boolean node to True and False, There’s some way to change it each time that I run the script?

I was thinking in a For loop with Python, but I’ve never working with it.

Thanks for your help!!

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

revitlinktypes=list()
linkcollector=FilteredElementCollector(doc).OfClass(RevitLinkInstance)
revitlinktypes=[]
for rli in linkcollector:
	rlt=doc.GetElement(rli.GetTypeId())
	revitlinktypes.append(rlt)
	TransactionManager.Instance.ForceCloseTransaction()
	rlt.Unload(None)

Hi,

At least you can unload it… with this,… maybe there is a user to put in a boolean :slight_smile:

KR

Andreas

You could create a .csv-file in which you save the last run state, .i.e. “False”.
Then from this .csv-file you could import the text together with a NOT node to reverse the input.

You can check to see if an element is already hidden in a view. Just use the opposite of that state when you run the graph. That way if the element is hidden, show it. If the element is visible, hide it.

4 Likes

Hi, Nick… How i can to know If a element si visible or not in one View?

I can’t find one node that help me

Thank’s for yuor help!!

Rhythm has a node or you can use the API method IsHidden.

1 Like

Thank’s for all Nick. I can to resolve the problem.

In this forum is the solution!