# Placing Legend component in Legends

**URL:** <https://forum.dynamobim.com/t/placing-legend-component-in-legends/7445>\
**Category:** Revit\
**Created:** [November 11, 2016, 12:06pm UTC](https://forum.dynamobim.com/t/placing-legend-component-in-legends/7445 "2016-11-11T12:06:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Younghwi\_Kim](https://avatars.discourse-cdn.com/v4/letter/y/f05b48/32.png) [@Younghwi\_Kim](https://forum.dynamobim.com/u/Younghwi_Kim)\
**Post date:** [November 11, 2016, 12:06pm UTC](https://forum.dynamobim.com/t/placing-legend-component-in-legends/7445/1 "2016-11-11T12:06:05Z")

</div>

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.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/5/750d16b74d959143ab3f64bbd5cd64ec75864ba9.JPG)

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”

---

<div class="post-metadata">

**Author:** ![Daniel\_Woodcock1](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@Daniel\_Woodcock1](https://forum.dynamobim.com/u/Daniel_Woodcock1)\
**Post date:** [November 11, 2016, 12:15pm UTC](https://forum.dynamobim.com/t/placing-legend-component-in-legends/7445/2 "2016-11-11T12:15:32Z")

</div>

Hi @Younghwi_Kim,

I’m not sure this is possible (I haven’t done much testing) but I came across this thread…

[http://forums.autodesk.com/t5/revit-api-forum/creating-a-legend-programmatically/td-p/4901598](http://forums.autodesk.com/t5/revit-api-forum/creating-a-legend-programmatically/td-p/4901598)

Cheers,  
Dan
