Assign View Templates to Views By Template View Name From Excel Data

ProjectStartup - 11-1-23.xlsx (14.6 KB)
NewProject-11-1-23.rvt (5.8 MB)
4_03_GetRevitnd(-elevations).dyn (109.5 KB)

Attached are files (modified) from the linkedin learning course, “Dynamo for Revit Project Setup - By Ian Siegal”

This dynamo script creates plan and ceiling views and places them on sheets. I would like to assign a view template to certain views.

In the excel file I added an additional column in the “Floor Plans” sheet(tab) titled, “View Templates” and put the name of a view template that’s in the rvt file in a couple of the cells. How would you script that in the attached dyn to make dynamo assign the view templates to the views by the name of the view template I inputted in those cells?

Hello @tony.z and welcome to the dynamo forum :slight_smile:

I´d recommend using the search function on the topics read from excel and apply view template.

https://forum.dynamobim.com/search?expanded=true&q=excel%20read%20order%3Alatest

https://forum.dynamobim.com/search?expanded=true&q=%22view%20template%22%20order%3Alatest

You can also search on youtube and google.

I suggest you start with something, when you get stuck show us what you got and we will help you to progress!

These 2 nodes should get you started! The view template node is from archilab package.

Kind regards!

Here’s where I’m at with this. It seems like I need to have some node between the List.Clean and the Views.SetViewTemplate but IDK yet… My novice mind is currently unable to generate a solution at this point in my learning journey.

We all started somewhere :wink:

When you share screenshots, make sure we can see error messages, they are very important.
Also open up the relevant node results (like you already did).

You could read the view template names from excel file, nice! But setting a view template is not as easy as you think :smiley: You can´t just input names in the SetViewTemplate node, as you can see it wants a view template as an input. Thats also what the error message tells you. It wants a view template but you gave a string as input. Understanding this error messages is crucial for your progress!

So you have to get the view templates, you know how to collect things in dynamo? Check out the “all elements of” nodes. They can collect elements of type, category or class. Can you find a way to collect the view templates of the project?

I´d also tidy up the graph a little^^


(no changes made here)

edit:
Look for these archilab nodes:

image

So many nodes… Though I feel like I’m getting closer to where I want to be. But how would I get the Views.ViewTemplate node to only apply to the indices that have the specified view template name (which are 6 & 7 in this case) under the View Template column in that excel file?

First you have to get the right view templates, your are now just putting all view templates into the node for setting templates.

What you have so far is a list of all view templates and a list of names, now you have to match them.
First you have to get the names from the view templates. If you want to get the names from elements, a super easy way is to just use a code block, write “x.Name” or “whatever.Name” or “banana.Name” into it. You can also use the element.Name node. Maybe this methods do not work for views and there is something like a view.name node?! Try it out!

If you have a list of all the view template names you can start matching. You can use a “==” node or a string contains node or a list contains node. As a result you want to have a bool list, so a list of true and false values. You can then use the filter by bool mask node to filter your desired view templates.

This is how to get your view templates, it´s a little tricky to set up the right lacing and list levels:

Some informations about lists:

https://primer.dynamobim.org/06_Designing-with-Lists/6-1_whats-a-list.html

That was tricky indeed… And for a minute I thought I got where I wanted to be with this script. Until I added another View Template name to the excel file and realized I have another sorting issue. So how would I apply the indices from 4,6,7 in list 1 to the indices 4,6,7 in list 0 shown in under the List.GetItemAtIndex node that is open in this image?

Great, the green part now successfully gets the desired view templates, as you can see this already works for different view template names! So I dont´t know what you want to do with the red part?!

Remove the red part and grab your views from node that created the floorplans. You just have to filter them so you get only the views that will get a view template applied, right?

Grab your view template names list and connect this node, this will create a bool mask for you that you can use to filter your floor plan views :slight_smile:

image

I had a feeling I was over complicating things when I created the contents in that red box. But this did it, your guidance helped me get the task done. Thank you so much @gerhard.p I appreciate the assistance.

1 Like

@gerhard.p I continued to add nodes to this project here. What I’m trying to do is create view dependents from the scope boxes I’ve made in this rvt file. BUT for some reason, after the first manual run, All Elements of Category doesn’t show all the elements of category and I think that’s one part of the issue here.

It accomplishes what I want to achieve but it doesn’t name the dependents (all dependent floor plan views after Level 1) with the scope box names I created as you can see from the project browser view below.
RUN1

BUT, when I run the script a second time, it does show all of the levels under All Elements of Category + it names the dependents with the scope boxes I created which is good, I don’t mind it creating additional dependent views…
WIP2
RUN2

… The only problem is, it names the additional copies with the name from the level below or with the previous level name. Should I have created another topic for this? Would you be able to help me out with this? Since this is kind of a continuation of this original project I’ve been practicing with.

NewProject (11-16-23) create dependents with scope boxes.rvt (5.8 MB)
WORKING _Views, sheets templates and scope box depenent assign (11-16-23).dyn (236.6 KB)
ProjectStartup - TZWORK.xlsx (14.2 KB)

So you think just because you place nodes on the far right in your graph, they will run later then the others? That´s not the way it works :smiley:

Calling the levels will most likely be one of the first operations in the graph because is a quick task, at this time your levels are not created. In dynamo it´s sometimes a problem that things all run at the same time. From time to time you will need a “wait for” or “pass through” node.

Here i used it and let it wait for the levels that have been created.

You can put anything you want into the wait input. As soon as this result is available the node will lett the elements on the “pass” input through the node to start processing whatever comes after.

Use this clockwork node or just put this in a codeblock:

[passthrough,waitfor][0];

If you want to know when things happen in graph i´d recommend to use tuneup.

Thank you. I understood that Dynamo executes all functions simultaneously regardless of node positioning. I mistakenly presumed it would smartly operate according to my preferences without supplying the necessary nodes to instruct Dynamo on what actions to take. Now I understand (thanks to you and this Tune-Up extension), that each node runs at a different time based on their execution speeds, and that this custom passthrough node can give me the ability to control an order of execution as well.

But I’m having a hard time determining the optimal placement of this passthrough node. Although! I did find a multi-step work around (through some trial and error) to get the script to create exactly what I want. Which is, create a dependent view from the plan names listed in the excel sheet and add the scope box names in the model to said dependent view names.

First, I run the script, then cancel out of the error that says, “The name entered is already in use. Enter a unique name.”

Second, I swap the wires connecting to the inputs in the passthrough node, then run the script again. And boom, I got what I wanted to achieve. I just know there is a better way to get there.

What’s the optimal position for a passthrough node in this graph to ensure that the script only needs to be executed once? Or maybe, multiple passthrough nodes are needed in this scenario. I’ll continue to do my research and trials. But if you have any additional insights to share, I would be highly appreciate it.

WORKING _Views, sheets templates and scope box depenent assign (11-22-23).dyn (166.5 KB)

1 Like

The passthrough is a super simple thing, but you not got it already.
You remember why we used it before? We wanted to collect levels that have been created in your graph, and we wanted to make sure they are collect after the creation.

What you are doing now: absolutely nothing :smiley:
If we ignore the list flatten node, you use the same element for both inputs of the node, that is not how it works.

In the first input you have to put the elements you want to use at a specific later time. These elements are waiting here.
You can decide when exactliy they will get sent through the node into the chain of following nodes, you do that with the waitfor input. This will ALWAYS be something somewhere else in the graph. And it does not matter what the input will be, it can even be a null or empty list from a failing node. As soon as this node gets ANY waitfor input it happily starts sending the waiting elements on their trip through the wires.

That sayd and without looking in the dyn, what is your intent here? Why do you want to use the node here?

Dude, I had tunnel vision on the wrong path. You’re right, I was creating nothing but a mess, I simply had to retrace some steps to get what I needed further back in the graph. It really wasn’t as difficult as I was making it out to be. Also, I had no need for the passthrough node. Once again, I appreciate your input and guidance, thanks you!

To add to it, if anyone is keen to read more about the need for passthroughs this might explain more about why this can happen - race conditions:

I like to analogize a passthrough node to the Megazord from power rangers. It can’t transform until all the Zords have arrived to combine. It might be a 2 part, 3 part of any number of inputs, but it wont go on until they’re all accounted for!

1 Like