Copying View Types and Templates from one Model to another

We are in the process of rolling out a new office template and I’m trying to copy certain elements from the new template into an existing project. For the most part I can Transfer Project Standards but this doesn’t copy View Types which is one of the things I’d like to transfer.

I’ve figured out how to retrieve all the View Types from the source model and copy them into another model with the below graph.

What it doesn’t do is copy the view template which is associated to the View Type (solving this probably leads to filters not copying but one thing at a time!) but I can’t figure this out and hope someone might know how to achieve this?

Hi
have you tried to get the view template with View.ViewTemplate (Clockwork) or Views.ViewTemplate (archilab), and then apply it to the new views with View.ApplyViewTemplate (SteamNodes) and Views.SetViewTemplate (Archilab)?

ViewTemplates

I have not, mainly because I don’t fully understand how to setup graphs in Dynamo to do what I want. I surprised myself by making the above based on a topic here that I found.

With regards to the nodes you’re suggesting, how would I apply a view template to a View Type? I should probably have added the below image which shows the View Type and Template assigned to it, both of which I’m trying to copy together.

Why would you want to do something with Dynamo that is one time only?
Just open two files in the same Revit session, select some views and copy/paste them in the other project.

If I can get it to work I’ll be running it on a number of models which don’t have the new View Types and Templates.

The only way I know of applying all the new View Types is by creating a callouts for each one with the correct template assigned, which I’m trying to avoid if at all possible.

The ViewFamilyTypes have a parameter called “View Template applied to new views”, the workflow is about getting this value and setting it to the new created types.
To do that we need first to filter the templates in the source document, pick the corresponding one, and applying to the new created elements.

ViewTypesTemplate

Give a try and let me know :wink:

Which package did you get “collector.elementsofcategoryindocument” from, I haven’t got it or can find it by searching.

They are all from Rhythm package (I edited the previous screenshot).
If you don’t find the node maybe you need to update the package.

I used to use this macro, the idea is to copy the view template to the clipboard and then paste into another view in another model. Sounds weird but works.

Worked in 2014, don’t know about newer versions.

Hi Lucamanzoni, I had to update Rhytem for the missing node. I get an error however on the second node in the “source Document View Type” group:

Warning: Element.GetParameterValueByName operation failed.
Could not obtain element from the current document! The id may not be valid.

I get other errors but I assume they are related to the above.

Franciscusm: I found that site/solution but I couldn’t figure out how to get it to work

Can you maybe post a screenshots with all previews visible? Are you sure the name of the parameter was written correctly?

I copy/paste the parameter name from your post as well as typing it out and getting a colleague to look it over. I’m probably missing something or maybe using an older package? Just in case it matters, the source file only has a couple of views in it, not one for each view type.

Is this what you meant with previews?

I tried changing to the Get Type Parameter node (ootb I think) which doesn’t give a warning. I do get this for the ListAllIndicesOff node: Warning: List.AllIndicesOf operation failed

—edit—

You have lacing set to auto, I don’t have that option (version 1.3.3)

The last 3 nodes are orange because instead of “false” you have to write simply false, or use a boolean input (look at my graph).
Can you post what it’s the error in node Element.GetParameterByValue?

I didn’t spot the code block error. This is what I get from the Element.GetParameterValueByName:

Warning: Element.GetParameterValueByName operation failed.
Could not obtain element from the current document! The id may not be valid.

It might be related to Dynamo versions.
Can you give a try connecting Element.Parameters to Collectors.ElementsOfTypeInDocument, to see what you get, and maybe post it?

You mean like this:

Warning: Element.GetParameterValueByName expects argument type(s) (Element, string), but was called with (Revit.Elements.Parameter, string).

Yes, but don’t connect it to Element.GetParameterValue.
Element.Parameters is just a monitor to look inside the element and see which parameters are available.
You should expand the preview, so we can see if View Template applied to new views is inside.

Number 9 in the list is blank for all list entries. I checked that specific one in my template file and the View type has he Template assigned to it.

I’ve also updated to the latest version of dynamo, just to be sure it’s not that.

You shouldn’t get en error, even if all are empty. Try to open my file and see what you get. I have Rhythm 2018.9.19, Revit 2019.1, Dynamo 2.0.1

CopyTemplateView.dyn (29.7 KB)

I tried it with your file, same results/error. I have the same package and Dynamo version but I’m using Revit 2017, I get the same result with Revit 2018.

I appreciate your help and time spent in trying to get to the bottom of this.

1 Like