Get view name and type by element parameter

I’m trying to get the View Name and Type from a long list of view elements, but can’t seem to consistently pull those two pieces of data off the data. I’ve tried reconfiguring and narrowing the script down to its essentials (posted below) but the behaviour is a bit mysterious to me. There are lots of examples of setting element parameters by type on the forum, but far fewer address simply querying those parameters.

Not all views are placed on sheets hence trying to use the View Name approach. For Type I was hoping to categorize the type of view (section, floorplan, etc.). Not sure why Familytype retrieves the correct info. I’m trying to get the info to a list for export and then further post processing for a business case.

Is there a reason you are using the map node instead of just feeding in the elements directly? Maybe try changing the lacing of the GetParameterValueByName to longest and remove nulls, but it should work better than using map.

As for why you aren’t getting view names reliably, that is because when you use category (views) -> all elements of category, you get view templates and other stuff included, which do not have view names.

So first you should filter by if they have a view name == “” (empty string) to get rid of templates, etc.

Getting the type parameter works but it doesn’t return a string, it returns the family, which is an element. To get what you want (Floor Plan, Section, etc), you need the name of that family. You can use Family.Name to get it. See below:

3 Likes

Well I suppose I see REVIT’s logic of having view templates as a view category but hadn’t thought to check that while troubleshooting and appreciate your feedback. Working through the code sample with some minor tweaks delivered exactly what I needed. I was just using List.Map because that’s how I learned Dynamo years ago, and now having moved onto other programming languages, find it a helpful reminder to know where I’ve mapped a function over a list. Nodes mapping over an element or list automatically can be frustratingly unpredictable and so I got out of the habit of trusting it. Happily Dynamo is improving over time so I will try the native way again if you suggest that functionally has improved as well.