Hide/Uncheck Visibility for Layer in Linked DWG CAD File


I am looking to hide/uncheck layers in a linked CAD file within a view like a Drafting View. There is documentation on how to change line colors, etc but I am having trouble pin pointing a way to simply hide a layer in a view via Dynamo/API. To shortcut initial steps I can use @Thomas_Mahon Bimorph Nodes to obtain all CAD Links and their Layer names. The Bimorph CAD.SetObjectStyle does not include an option for turning off a layer by name. Is there a way through the API or functionality in the Bimorph nodes that allows me to do so?

1 Like

Same here… This would potentially save an enormous amount of time when dealing with many CAD links on many view templates.

I didn’t see this post, but its easy to implement so I’ve added CAD.SetLayerVisibility to the next release of BimorphNodes. ETA Q1 or early Q2.


Will this control linked CAD layers in View Templates?

Thanks Thomas,

That’s fantastic, just for my curiosity (and perhaps in the meantime), would you mind helping me do it with Python?

I believe I need the sub-category of the import instance, but I can’t find much in the API to get methods for these? Dir didn’t give me a visibility or hide… I had a try with SetCategoryHidden and the import instance class tells me:

To hide or unhide an element, use the Hide() and Unhide() method of [View ]

But nothing has worked :frowning:

Any hints welcome :slight_smile:



Import instance methods :http://www.revitapidocs.com/2018/3f3ed4b4-2d17-de4f-db5f-8363d008a040.htm
Sub-category property: http://www.revitapidocs.com/2018/e2f50049-832c-9b72-70b1-2a0a96e16a60.htm

#thanks to KSobon, TMahon, Koz Jono YEOH and everyone else

import clr

import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc =  DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

view = doc.ActiveView.Id #UnwrapElement(IN[1])
DWG = UnwrapElement(IN[0])
lyrsIds = List[ElementId]()

    lyrs = DWG.Category.SubCategories.GetEnumerator()
    while lyrs.MoveNext():
except: pass

for lyrId in lyrsIds:
        Output = 'Success'
        Output = 'Fail'

OUT  = Output, lyrsIds,

Hi @Mark.Ackerley

No problem, just get the category of the import instance then its sub categories:

#Copyright 2019. All rights reserved. Bimorph Consultancy LTD, 5 St Johns Lane, London EC1M 4BH www.bimorph.com
#Written by Thomas Mahon @Thomas__Mahon info@bimorph.com Package: BimorphNodes
#GitHub: https://github.com/ThomasMahon/bimorphNodes/
#Follow: facebook.com/bimorphBIM | linkedin.com/company/bimorph-bim | @bimorphBIM

import clr

# Import ToDSType(bool) extension method
import Revit

# Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

importInstance = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
layerName = IN[2]
visible = IN[3]

doc = DocumentManager.Instance.CurrentDBDocument


catSub = importInstance.Category.SubCategories
cat = catSub.get_Item(layerName)

cat.set_Visible(view, visible)


OUT = importInstance

Hi @Thomas_Mahon

Thank you for the speedy response :slight_smile:

Can you help me workout where the get_Item and set_Visible live in the api docs? I can’t see a sub category class?

PS I deleted ‘Document doc = DocumentManager.Instance.CurrentDBDocument’

PPS I’m still getting an exception?

Hi @edanastas i thought it would, since a VT is just a view from Revits perspective, however it throws an exception…so no! I’ll look into this before release.

EDIT: Yes, it works, there was an exception occurring within my test file. Simply pass you view template in as the view and it will work without issue.

1 Like

I copied my code from C# then redacted it and missed that… so you need to remove the Document type from the doc object (C# is strong-typed) declaration as you will need this line, i.e.:

doc = DocumentManager.Instance.CurrentDBDocument

I’m testing in D 1.3.4 and R2018:


Sweet, that’s working :slight_smile:

Thanks again!


I’m a little new at this… I have the “View Template” Library element. What would I do with that to drill down to set the layers within it?


@edanastas download BimorphNodes v3 and use the new CAD.SetLayerVisibility node (your view template is a type of view, so input it into the view input)

Hi Thomas,

Can you help confirm a few things about the functionality of this node?
-Can it be used to access DWGs from a linked model? I did not have any luck during my attempts.
-Can you elaborate more on the type of views it will take. Will it work with Area Plans?
-Do you know why i am getting the error below?

Original Issue:
The architect is using CAD links in their views for some parts of floorplans and we want to be able to hide a specific layer that they are using to cloud items for an addendum. I was not able to use this node from my model so my compromise it to make the changes in the linked Arch model directly.

Thank you for your help