from Autodesk.Revit.DB import *
from pyrevit.forms import alert
doc = __revit__.ActiveUIDocument.Document
all_views = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).ToElements()
all_legends = [view for view in all_views if view.ViewType == ViewType.Legend]
if not all_legends:
alert("There has to be at least 1 Legend View in the project! "
"Please create one and try again.", exitscript=True)
random_legend = all_legends[0]
new_legend_view_id = random_legend.Duplicate(ViewDuplicateOption.Duplicate)
new_legend_view = doc.GetElement(new_legend_view_id)
new_legend_view.Scale = 100