Hi all,
I was trying to modify mostafa’s code here and use it to copy/duplicate one view template multiple times.
changed the code part:
copyid = ElementTransformUtils.CopyElements(doc, elementlist, doc, Transform.Identity, CopyPasteOptions())
to
copyids = ElementTransformUtils.CopyElement(doc, view.Id, XYZ.Zero)
the reason why is to get also the actual changes in view template not only the view itself.
Using Copy Paste Option:
XYZ:
The code is working with only one copy but what i want to do is to create a template and then duplicate it multiple times.
#Copyright (c) mostafa el ayoubi
#Node-mode 2016 elayoub.mostafa@gmail.com
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import*
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
# The inputs to this node will be stored as a list in the IN variables.
views = tolist(UnwrapElement(IN[0]))
names = IN[1]
doc = DocumentManager.Instance.CurrentDBDocument
ids = [view.Id for view in views]
newviews = []
# ForceClose Transaction
TransactionManager.Instance.ForceCloseTransaction()
# Start New Transaction
t = Transaction(doc, 'Duplicate View Template')
t.Start()
copyids = ElementTransformUtils.CopyElement(doc, view.Id, XYZ.Zero)
for id,name in zip(copyids,names):
newview = doc.GetElement(id)
newview.Name = name
newviews.append(newview)
# End Transaction
t.Commit()
# Assign your output to the OUT variable.
OUT = newviews
Thanks in advance.