Create new view and apply view template to that view

Dear all I tried to create a new view in the document and try to apply the view template that I have inside the document. attached the screenshot for your reference.

You create the view and then you get the view template from that view and try to apply a template to the template instead of the actual view. You should just have to get rid of the View.ViewTemplate node.

@Nick_Boyts thanks for the reply but i am trying to use the template I already have inside my document but its not applying to the newly created view

That’s fine but you still have to apply the template to the view. View.ViewTemplate gets the template assigned to the view (if there is one). You’re currently attempting to assign a view template to a view template. You need to remove that node regardless, but I’m guessing View.ApplyViewTemplate pulls the templates from the active document. Is there a reason you’re not just running the graph in the appropriate Revit file?

I tried that already its creating the views but its not applying the view template

As I said, the node probably looks at the active document, not the one with your new view. Why aren’t you running the graph in the document with the view and view template? If you’re wanting to do this to multiple documents at a time then you’re going to have to modify the python code in the custom node to accept a specified document so it knows where to look for the new template.

yes I want to run it for multiple documents but I am not familiar with python codes

If you edit the custom node I’m guessing it’ll just be a single python block. You can copy/paste the python block out out of the node and into your graph so that you can modify it there. Then you just edit the python code to take an input document instead of automatically reading the active one.

The python code should have a line similar to this:
doc = DocumentManager.Instance.CurrentDBDocument

Change it to:
doc = IN[2]

Then you can feed in the view’s document to IN[2] so that the code checks that document when looking for view templates.