Compile a list of all linked CAD categories and subcategories (layers)?

I am extremely new to Dynamo and have done hours of searching online for this solution but maybe there is help for me out there? I am looking for way to compile a list of all of the subcategories (layers) of all of the linked CAD files in my revit model. I need to take this cumulative list and either be able to change the graphic/visibility overrides on a global scale (ie - hide the layer “ROOMNU” in each linked file of the model) so I can save these settings as part of a view template. If saving as a view template is not possible I’d be OK with exporting this list of layers to Excel and making the changes and exporting it back into the dynamo file.

Without this, for each view template that I set up where the linked files are acting as underlays, I have to scroll through over 100 layers (not mine…the architect’s) to cherry-pick the 12 or so I might need visible. Multiply that by the nearly 100 Revit models I will be creating (where the plans for each floor of a building exist as one .dwg per level for nearly 100 buildings)

Thank you in advance for any advice!

Read this: How to ask for help.

Right now, you are showing zero (0) work. You are not posting any samples. You are basically giving us some story that no one really cares about, and asking us to do your work for you. Great, but not the right place to do that. This is a community forum, not a red cross charity for architects/engineers on a deadline. The link above explains how a typical community forum functions and what are the rules for asking good questions. Do your work, and we will help you get over the finish line. Don’t do your work and you get a nasty comment like this.

Cheers!

Hi Holly,

I’m pretty new to Dynamo as well, and it’s all a bit daunting - especially if you don’t have a programming background.

Zach Kron has a post on his blog about his experience putting together a quadcopter from scratch, and that he now understands what it feels like for us 'just an architect' types to face Dynamo! heh heh heh, hey Zack, want me to put that quad together for you? They're pretty easy; I've built about 3 from scratch! :-D
What you are doing with your subcategories sounds a lot like what I'm doing with them, and for similar reasons. I have to manage a large (18,000 object) set of families for detailing hospitals, and the latest official set from the government standards team was outsourced... so it's got a LOT of extraneous / incorrect / mis-spelled subcategories that need cleaning, and I though using Dynamo to put them all into a spreadsheet might make this 6-month job a bit easier.

TLDR;

Pictures at end of post, Links to DYN code mentioned in post: subcategory category lister2 category lister1 category lister

The examples I have provided do this (use a Revit sample file, like the Basic House, as a test file)

Category jiggery.dyn - shows how different nodes handle (or don’t handle) Categories & Subcategories

Category Lister.dyn - how I am extracting Categories from each object in my document.

Category Lister 1.dyn - shows how Categories obtained from an Element are NOT equivalent to Categories obtained from the Document, even though they appear to be exactly the same! I think the output from an Element is just a String, rather than the magic thingy that is a Category.

Category Lister 2.dyn shows how I can get the Category.Id.Value as an integer from both Dynamo native Nodes, and my own custom-coded Python node - but I then can’t do anything with it, like Get a list of associated Subcategories. More detailed explanations of what is & isn’t working below! <!–more–> Unfortunately I’ve hit a few, actually, a LOT of hitches, examples of which I have provided with this post.

The big problem is that there is no ‘native’ handling of Subcategories in Dynamo. You have to either use what tools are available in packages, some of which work, some of which don’t, or code your own in Python. I don’t know Python, but I’m starting to pick it up from fiddling with things. I’ve also found you can really easily break Dynamo doing this, especially if you didn’t realize that editing the Python code in a code block in your project also edited it in the package definition. Ouch.

The second big problem is that the tools available that do reference Subcategories / Categories (mostly from native Dynamo, Clockwork & Lunchbox) don’t reference them in a consistent way, and worse, don’t actually specify how they reference them! Without delving into the detail of Cat / SubCat in Revit - some tools reference BuiltIN Categories, some reference CategoryMap Categories, some expect one but not the other. Some don’t seem to work with either! Some tools will take STRING inputs, some will only take ummm… I don’t even know what it’s called - ‘Wrapped Code’? - inputs.

Example. The Native Dynamo CATEGORY node gives you a select box to pick a Category from the BulitIn list; but outputs a category from the CategoryMap list. So what? Well, try selecting ‘Speciality Equipment’. (yes, it’s spelled that way!) - it outputs ‘Specialty Equipment’ - because thats actually what it’s coded like in Revit! The out is also not a String… it’s a… whatever it is. Code? Data?

Now use a Node to identify Category from an Element - you will get something like “OST_SpecialityEquipment” - which is the full BuiltIn name, and might, or might not then work with another node that takes Category as an input. The only way to match Categories reliably in the API is to use the ID Value, and there are countless examples that do just that; you can extract the Category.ID with in Dynamo - but there is no way I can find to then use the Category.ID - I have no idea how to ‘reverse lookup’ the Document CategoryMap or BuiltInCategory table to obtain the name corresponding to the ID value. All the Revit API examples are given in languages other than Python, so they aren’t a lot of help to someone who doesn’t even know those languages, let alone Python.

The examples I have provided do this (use a Revit sample file, like the Basic House, as a test file)

Category jiggery.dyn - shows how different nodes handle (or don’t handle) Categories & Subcategories

Category Lister 1.dyn - shows how Categories obtained from an Element are NOT equivalent to Categories obtained from the Document, even though they appear to be exactly the same! I think the output from an Element is just a String, rather than the magic thingy that is a Category.

Category Lister 2.dyn shows how I can get the Category.Id.Value as an integer from both Dynamo native Nodes, and my own custom-coded Python node - but I then can’t do anything with it, like Get a list of associated Subcategories.

Aside - see the little bit of Python that extracts the Subcategory names? Sometimes, when I type it in exactly the same it gives me EOF errors. The way to doing via a Python-From-String Node never works at all for me, despite typing it exactly the same. I know about the importance of spaces, so I have a snippet in Notepad++ I copy and paste when I need it - and sometimes that works! About 50% of the time it gives EOF errors though. I just delete the Node and do it all over again. Sometimes it runs perfectly once, or twice, or three times, then suddenly it does the EOF error thing, and needs to be deleted again. Sigh. Subcatpy.png shows an example of this - the Script String is exactly the same as the direct Python node - one works, the other doesn’t. This file also shows what I am trying to do - output an Excel spreadsheet, with a separate Sheet for each Category, listing each SubCategory for each Category, except autometically, without needing 50+ separate code flows for each Category (there can be hundreds!)

At this point I’m at an impasse - my boss is a bit dark about me spending 8 hours trying to do this; so I’m back to doing it manually - screenshoting the massively long Object Categories list in Revit, stitching the images together, then using OCR to extract the text, then correcting the OCR errors, then pasting that in Excel. Yes it takes longer!

All we really need is a reliable way to list and edit (rename, maybe delete?) Subcategories.

Dynamo seemed easier than learning C# and the API; and at least I’ve learned some Dynamo!

and… wow, Chome really doesn’t like this edit window!

[caption id=“attachment_43126” align=“alignleft” width=“706”]category jiggery Category Jiggery. Note Category.Id nodes failing despite being given “valid” Categories.[/caption]

[caption id=“attachment_42782” align=“alignleft” width=“689”]subcatpy SubCat to Excel flow, showing small Python script failing from STRING, but working from cut/paste from Notepad++ - the same text![/caption]

[caption id=“attachment_43138” align=“alignleft” width=“734”]Category lister part a1 Cat Lister 1 - Categories from Select box can be SubCatted, Categories from Elements CANNOT, Category by ID CANNOT[/caption]

[caption id=“attachment_43137” align=“alignleft” width=“748”]category lister part 2a Cat Lister 2 - my own Python gets Cat.Id, which matches Dynamo Cat.Id - but can’t turn this back into Category to be usable.[/caption]