Transfer View Templates from Template file


I am trying to get a script to transfer the View Templates to existing models from our company Template model file.

The script stops with a prompt when it finds Duplicate Types in the target model. After clicking OK the script just stops and fails to proceed to the next View Templates.


Any thoughts on how can I overcome this obstacle and either choose to always overwrite or not any duplicates found or allowing for the script to continue when this window ensues?

script attached.
Thank you
MANAGE - Push Template settings.dyn (17.7 KB)

I assume you’re transferring specific templates only and that’s why you’re not using TPS. If that’s the case, then you must have a list of templates to import in your graph somewhere. Simply check your existing templates for duplicate names and delete them before transferring the new ones.

Hi @Nick_Boyts,

Thank you for the reply.

The Duplicate Types warning I am getting is for the View Filters that are within the View Templates.
And I should consider the option that I may want to override them, since the goal is to push the default template settings to existing models.

does this make sense?

Can you post an image of your graph, with all necessary node outputs shown, so we can see what’s going on? Also, what method are you using to transfer properties?

It’s likely that there isn’t a good way to access the dialog you’re seeing and the better solution will be to just avoid it. The easiest thing to do would probably be to rename the existing filter. You could then have your script replace it after the transfer, or leave it as a manual task (may be worth keeping in some situations?).

Of course.
Image below.

I am using a collection of Rhythm nodes (from @john_pierson) top open the source file and copy the View Templates by Id to the target file.

1 Like

Are you sure the warning is from existing templates? You’re copying the templates via all views, rather than all templates. This means you’re copying over most of your templates multiple times. Rather than View.ViewTemplate, I would use View.IsTemplate to filter down only the template views.

Also, why not use Transfer Project Standards? You’re not transferring specific templates. You might as well use the built-in tool designed to do exactly what you’re trying to do.

1 Like

@Nick_Boyts, thank you for pointing that out.
I have corrected the way the View Templates are collected.

The reason for not using the OOTB Transfer Project Standards is that I want to be able to also copy a selected set if required.
The new script has been expanded to include Data-Shapes nodes so to allow for this selection.

I am, however, getting the same Duplicate Types warning as before.
MANAGE - Push Template settings.dyn (55.4 KB)
Please see attached.

Again, you’re going to be better off fixing the issue of having duplicate names before transferring rather than trying to deal with the warning after the fact.

I appreciate that, @Nick_Boyts, but, following your previous comment, I no longer have duplicated View Templates. The Duplicate Types that I am getting has to do with Filters that are being used in more than one View Template that is being copied.

This is the obstacle I am trying to overcome with this script.

Does this make sense? I allow I may be misunderstanding your reply, also.

You can get the filters applied to each template before copying it. Then you can look for filters in your current project with the same name, delete or rename them, and then continue with the transfer.

1 Like

Ideally, I’d prefer to have the option to either overwrite or ignore the filters in the current project.
If I delete the existing filters I may accidentally be removing them from other Views/View Templates that I would like to keep.

Search the Appstore for Tranfer Single.

1 Like

Thanks @Marcel_Rijsmus.
I am aware of such tool. But I would like to create a bespoke tool.

You would have to check your existing views for the filter and add it back after removing them. These are all common scenarios when trying to reconstruct a more involved Revit process. Not everything is available in the API, especially when it comes to dealing with dialog boxes and the UI. You have to recreate some of the functionality on your own.