Renaming Views – Dereferencing a non-pointer and "Name cannot contain any of the following characters:"

Hi have a script where I can rename views. I have been trying to add a filter where I filter out all Legend views but the graph is now giving the error “Dereferencing a non-pointer”.
I am not sure were I went wrong but would appreciate some feedback

Thanks
JH
Rename Views On Sheets.dyn (16 KB)
error

Looks like you are no longer feeding view elements into the set parameter value by name node, but instead you’re feeding it view types which don’t have a view name parameter.

Try this:

Thank you Jacob,
I tried the graph as suggested and I still got an error - please see attached
Will have a look at it again later.
Thanks
JH

screenshot.

Hi,
I did some modification to the graph – please see below but now I get the error

Name cannot contain any of the following characters:
\ : { } | ; < > ? ` ~
or any of the non-printable characters.

Going though the graph I can’t see why I et this error as I have not added any additional characters.
Thanks
JH

Rename Views.dyn (31.9 KB)

Previously the lower half of your graph was working, so it may be that you have a selection issue. What are the errors?

Hi,
The graph is actually not generating any erros - but revit give me the below error. I know that the chracters can’t be used in view names but I have not introduced any of them in my naming …so I am not sure what is happening.
JH

Can you post your .rvt file?

Hi
I have used the rst_advanced_sample_project as my sample project.
The error occuer even if the sheet doesn;t have a legend view
I have uploaded the model here https://www.dropbox.com/s/s0iqgxcw3p3cqje/test.rvt?dl=0

Thanks
JH