How to get a list of views that do not have a view template applied

How to get a list of views that do not have a view template applied

mitchellpUDG9S
Explorer Explorer
2,644 Views
12 Replies
Message 1 of 13

How to get a list of views that do not have a view template applied

mitchellpUDG9S
Explorer
Explorer

Hi everyone,

 

I am using the Revit "Model Checker" tool top run a few tests and I keep getting stuck with the test of "Views with no View Template Applied".

I currently have OST>Views>Include and then

API Parameter>IsTemplate>not equal

What this seems to do is return a list of all of the views in my project, because I think what the test is doing is simply testing if the VIEW itself is a template or not. And because its not, it returns everything.

How do I actually run a test that will look at the views, test if they have a view template applied, and if they do not, return a list of the views that don't have any view templates applied?

Any assistance with this would be greatly appreciated!

Thank you!

0 Likes
2,645 Views
12 Replies
Replies (12)
Message 2 of 13

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @mitchellpUDG9S ,

1)Get a view

2)Get ViewTemplateId from the view

 ElementId templateId = view.ViewTemplateId;

3)If ViewTemplateId is  "-1", there is no template set for this view.

4)Add this view to the view list that does not have a view template applied

5)If ViewTemplateId has value, then viewtemplate is applied for this view.

 

Try this and let me know whether it solves your issue or not.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 13

mitchellpUDG9S
Explorer
Explorer

Hi Naveen,

 

Thank you for the reply, sorry I am taking so long to get back about this.

mitchellpUDG9S_0-1615271230429.png

I have tried to add your API parameter called "view.ViewTemplateId" = "-1", but the result that I get is a list of views and view templates. I don't use this Model Checker very often so I am trying to figure out how to get things right but I cant seem to find too much help online about how to arrange things.

I am not sure how to take the list of views and view templates and apply a rule to search for views that do not have the template applied. 

Wondering if you could perhaps give me some direction here?

0 Likes
Message 4 of 13

franciscopossetto
Advocate
Advocate

Hey,

 

You just need to write ViewTemplateId in the model checker property. It should work.

Also, As you mentioned in the post I would add the IsTemplate property in order to check those Views that are not ViewTemplates

 

t.png

 

I hope it helps.

Kind regards

Github:
https://github.com/franpossetto
0 Likes
Message 5 of 13

mitchellpUDG9S
Explorer
Explorer

Hi Francis,

 

I filled in the fields exactly as you have them and I still get a list of both View templates as well as physical views.. Right at the bottom it also says "Failed to apply API Parameter filters". Any ideas?

mitchellpUDG9S_0-1615359402635.png

 

0 Likes
Message 6 of 13

franciscopossetto
Advocate
Advocate

Hey,

 

Which version of Revit are you using? It Worked in my model, I am using R2020.

 

franciscopossetto_0-1615378456354.png

 

I have attached the xml. Let me know if it still fails. 

 

I hope it helps,

Kind regards.

Github:
https://github.com/franpossetto
0 Likes
Message 7 of 13

mitchellpUDG9S
Explorer
Explorer

Hi,

 

Hmm, I think we may be trying to do the opposite thing here, I see yours says "ViewHasTemplateApllied" I am trying to figure out which views do NOT have a template applied to them and list only those views.

This is what I have:

mitchellpUDG9S_0-1615379531475.png

Too my understanding, the first line collects the views, the 2nd line filters out the items which are view template, leaving you with only views, then the third line checks the view template id to see if it has a value, -1 means it does not have a template applied. (I would like this list of views)

This is how understand this but I might very well be wrong:( If I am wrong, would you know how I should tweak it in order to get the desired results? 

I am using Revit 2019 here.

0 Likes
Message 8 of 13

franciscopossetto
Advocate
Advocate

Hey,

 

Yes, you are right about the name. It should be ViewsDontHaveTemplateApplied.

What you have described is also correct, we are counting those Views that are not templates and have as ViewTemplateId the value -1. 

 

Look at the Preview description below, on your image. You have written ViewTemplateId.name on the Property input. You should write just ViewTemplateId.  It should work after you do this modification.

Github:
https://github.com/franpossetto
0 Likes
Message 9 of 13

mitchellpUDG9S
Explorer
Explorer

Ahh thank you so much Francis, it's working now!!

I put the .Name in there after it wasn't working previously to see if it would help and I forgot to remove it.

Thanks so much for your assistance, really appreciate the help!

0 Likes
Message 10 of 13

franciscopossetto
Advocate
Advocate

Happy to help! You are welcome.

Github:
https://github.com/franpossetto
Message 11 of 13

Sean_Page
Collaborator
Collaborator

I might recommend using view.ViewTemplateId == ElementId.InvalidElementId in lieu of the -1. I have had minor issues using the integer value.

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 12 of 13

mitchellpUDG9S
Explorer
Explorer
Hi Spage,
I will give this a try as well thank you.
0 Likes
Message 13 of 13

mitchellpUDG9S
Explorer
Explorer
Thank you very much for your help Naveen, I see now that you were saying the same thing from the beginning, I just didn't have the knowledge to know exactly what I was looking at yet:)
0 Likes