Automatic legend

I’ve been lurking for a while here on the forums, always very useful stuff.
At the moment I am trying to create an automated legend that shows only the pipe and duct system types that are actually visible in the corresponding view.

Using All Elements in View(s) I can retrieve the visible systems, but I fail to translate that into a legend.
My first thought was to have an existing legend with all available systems (a line with the system color defined in its line style and a text with the system name), duplicate it, and then use category overrides to hide the lines. The texts though, they’d still be there and there’d be free spaces in my legend. I couldn’t get anything to work here, legend views are treated differently, can’t find a way to hide the different line styles.

The second approach was to use detail groups of the different systems consisting of the line, text and maybe a frame around them. I would then have them placed one after the other by the script if the system was visible in the view. Unfortunately I couldn’t find out how to place these detail groups in a legend or in a drafting view.

Has anyone pulled this off yet? Maybe some hints would help me get into the right direction

I have done this in a Non-Dynamo way involving parameters, schedules containing ‘Type Image’ and filters

I add a a parameter ‘Visible on X’ for example to the elements I want to show/hide/schedule. Then apply a filter to the view to hide/override all elements which don’t equal Yes and do the same to the schedule. Add Type Images of what you want to show on the schedule to the families.

It’s a bit annoying having to get an image of all the families and assign them to the appropriate types, however this way once it’s set up you don’t need to re run any dynamo graphs to update it.

Not what you were looking for but might be worth trying if you can’t find another way :slight_smile:

That’s one way to do it. However I want to avoid creating a load of files for this.
I almost feel like automatic legends should be a feature of Revit. It’s probably possible via the Revit API or custom python nodes in Dynamo but I’m not familiar with coding.