Im after help on how to grab all active View templates within my revit project with dynamo and turn off the import element of VG so that all my views do not get contaminated with imported AutoCAD dwg.
Ideally, I need this as a dynamo script as I have hundreds of projects to repair.
I may want to filter by view name, i.e., begins with βXX.β
Hi,
Iβm not sure this function is available in Revit API, a workaround is to disable categories (CADLink)
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
viewtemplates = DB.FilteredElementCollector(doc).OfClass(DB.View).ToElements().FindAll(lambda x : x.IsTemplate)
cadlinkTypes = DB.FilteredElementCollector(doc).OfClass(DB.CADLinkType)
TransactionManager.Instance.EnsureInTransaction(doc)
for view in viewtemplates:
if view.Name.startswith("XX."):
for cadlLnkType in cadlinkTypes:
if Element.Name.GetValue(cadlLnkType).endswith(".dwg"):
view.SetCategoryHidden(cadlLnkType.Category.Id, True)
TransactionManager.Instance.TransactionTaskDone()
OUT = cadlinkTypes
Thanks for this, im totally new to the dynamo, how do I use this in a script. Does this need adding to a python node then attached to some input / outputs?