API - View ElementId error

Hello. I am having some issue with this python script I am making, which uses RevitAPI to duplicate views and change the name. I can duplicate the views just fine but when I want to access the name parameter, it is telling me that I am trying to access an ElementId which has no get_Parameter attribute.

If I understand my code correctly, the duplicate command returns the newly created view’s Id and not the view itself, which is why I have the error.

How would I go about getting the newly created view from duplicate instead of using the Id that it gives me?

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#The inputs to this node will be stored as a list in the IN variables.
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
views = []
dupview = []
c = 1
for i in IN[1]:
	newView = UnwrapElement(i).Duplicate(ViewDuplicateOption.Duplicate)
	newView.get_Parameter(BuiltInParameter.VIEW_NAME).Set("Revision Cloud View " + c)
	dupview.append(newView)
	c += 1

TransactionManager.Instance.TransactionTaskDone()

Uploading…

Thank you.

1 Like

Nevermind, I got it.

newViewId = UnwrapElement(i).Duplicate(ViewDuplicateOption.Duplicate)
newView = doc.GetElement(newViewId)