I’m trying to create a script that looks at all my views that have specific view templates. Then based on each view template the script would apply template properties to each view.
For example:
View Templates that are actually used in each view:
Template A
Template B
Template C
Apply template properties view templates:
ApplyTempA
ApplyTempB
ApplyTempC
So in this hypothetical, Template A would always need “ApplyTempC” to be applied.
Template B = “ApplyTempB”
Template C = “ApplyTempA”
Is there a node that lets me get all the available view templates in a project?
I’ve attached a picture of what i have so far. Any advice is appreciated.
ViewTemplates are part of the View class, so that list of all Views in your project includes all the ViewTemplates as well. There should be a node (IsTemplate) that will let you identify which are templates and which are project views.
I ended up using View Type and Views.GetByType, and that looks like it’s giving me all my view templates. If I try to filter by the template name having an “_” or “ARCH” it doesn’t filter. I think that’s because the list of view templates aren’t strings? When I look at the parameters of the templates, all of the “Name” parameters are blank. Do i need to convert the list to a list of strings or is there something i’m missing? Also not having any luck finding a node that converts the list to a string.
It’s hard to tell from your image, but that sounds correct. The view templates you have are elements and need to be strings in order to check for substrings. Element.Name should work. Not sure why it shows blank in the parameters. You could also use String.FromObject to force the string, since the element object does contain the name already.
Making progress, thanks for the help!!
Is there a way to convert a list to a code block? so i can make each string in the list a separate connector? If that makes sense?
First, I would highly suggest you go through the Dynamo Primer. It goes over all the basics and includes examples for all this stuff.
A list is defined by square brackets. A string is defined by quotes. ["string1","string2","string3"];
A list is a single object so it would be a single connector. If you want a connector for each item then they would have to be defined as individual items. Your current code block is defined with variables but some have invalid characters in their name, causing the error.
What are you trying to do? Why do you need to separate everything in your list?
The next step would be to say if View Template Elec Power, apply _ARCH-PWR template. So i figured if i had a code block connector for each template it may be easier to manipulate the if statements? And I did some googling on separating the list out to a code block but didn’t find anything.
There’s no need to separate as you would just let Dynamo iterate through your list. It’s also not possible to separate a list of single objects into multiple individual objects. Code blocks (and python) are the only places where you define individual outputs, but even then they have to be defined. There’s no way to automatically define them and separate the list.