Does anyone have experience placing legend component in legends.
I want to place all structure legend component that i used in model with tag, but it is too difficult for me.
Detail of custom node is below.
import clr
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference(“RevitAPI”)
from Autodesk.Revit.DB import *
def tolist(obj1):
if hasattr(obj1,“iter”): return obj1
else: return [obj1]
legends components = tolist(IN[0])
locs = tolist(IN[1])
viewports =
failed =
i = 0;
if len(legends components) == len(locs):
for v in legends components :
loc = XYZ(locs[i].X, locs[i].Y, locs[i].Z)
legends components = UnwrapElement(v)
if view.ViewType != ViewType.Schedule:
Legends = UnwrapElement(v)
canAddToLeg = Viewport.CanAddViewToLegends(doc, sheet.Id, view.Id)
if canAddToLeg:
try:
if view.ViewType == ViewType.Schedule:
TransactionManager.Instance.EnsureInTransaction(doc)
viewport = ScheduleLegendsInstance.Create(doc, sheet.Id, view.Id, loc)
TransactionManager.Instance.TransactionTaskDone()
viewports.Add([viewport,Legends])
else:
TransactionManager.Instance.EnsureInTransaction(doc)
viewport = Viewport.Create(doc, sheet.Id, view.Id, loc)
TransactionManager.Instance.TransactionTaskDone()
viewports.Add([viewport,Legends])
except:
failed.Add([“Failed”,Legends])
else:
failed.Add([“Failed”,Legends])
i = i+1
OUT = [viewports, failed]
else:
OUT = “Error! The number of views you want to place must match the number of Location Points”