# Python List Output

**URL:** <https://forum.dynamobim.com/t/python-list-output/32444>\
**Category:** Uncategorized\
**Created:** [February 21, 2019, 8:56am UTC](https://forum.dynamobim.com/t/python-list-output/32444 "2019-02-21T08:56:10Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [February 21, 2019, 8:56am UTC](https://forum.dynamobim.com/t/python-list-output/32444/1 "2019-02-21T08:56:10Z")

</div>

Hey,

Would anyone mind helping me control my output to match the input lists here?

I can fix it with nodes, but I would like to better control my python code 🙂

(if there was a way of removing the need to list cycle the sheet input, that would also be cool!)

![image](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/1/a/1a9eb41cfae7f9ca917a8c178bd5ac70e2922d42.jpeg)

```
thanks Konrad et al!
import clr
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

revisions = UnwrapElement(IN[0])
sheets = UnwrapElement(IN[1])

revs = []
r = []
Output = []

for sheet, revision in zip(sheets, revisions):
    for sht, rev in zip(sheet, revision):
        r = Autodesk.Revit.DB.ViewSheet.GetRevisionNumberOnSheet(sht, rev.Id)        
        Output.append(r)
        

OUT = Output

```

[test.dyn](https://forum.dynamobim.com/uploads/short-url/yo3WMY4zgXtqszaInDrkrRHhOW8.dyn) (10.2 KB)

Thanks a lot 🙂

Mark

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 21, 2019, 9:22am UTC](https://forum.dynamobim.com/t/python-list-output/32444/2 "2019-02-21T09:22:08Z")

</div>

Hello. Can you give a sample revit file too? Or a dummy dynamo file that doesn’t need Revit

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [February 21, 2019, 9:29am UTC](https://forum.dynamobim.com/t/python-list-output/32444/3 "2019-02-21T09:29:53Z")

</div>

Sure, thanks!  
[test.rvt](https://forum.dynamobim.com/uploads/short-url/bqAQNGy3aTyOSMHU5gMnYIOaWTq.rvt) (1.1 MB)

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 21, 2019, 9:37am UTC](https://forum.dynamobim.com/t/python-list-output/32444/4 "2019-02-21T09:37:21Z")

</div>

Something like this?

 ![sheetrevision](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/b/1bb37b2d3f2e855fe35e623857c23ade8c3572c8.png)

```
# Copyright(c) 2015, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

revisions = UnwrapElement(IN[0])
sheets = UnwrapElement(IN[1])

revs = []
r = []
Output = []

for sheet, revision in zip(sheets, revisions):
    revnum = []
    for rev in revision:
        r = Autodesk.Revit.DB.ViewSheet.GetRevisionNumberOnSheet(sheet, rev.Id)        
        revnum.append(r)
    Output.append(revnum)
        
OUT = Output
```

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [February 21, 2019, 9:47am UTC](https://forum.dynamobim.com/t/python-list-output/32444/5 "2019-02-21T09:47:13Z")

</div>

You make it look so easy 😃

Cheers!

Mark

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 21, 2019, 9:54am UTC](https://forum.dynamobim.com/t/python-list-output/32444/6 "2019-02-21T09:54:48Z")

</div>

No problem. If you want to see a really complicated version, here are two others that work, one using an embedded for loop and the other using a lambda function inside an embedded for loop 😀

```
# Copyright(c) 2015, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

revisions = UnwrapElement(IN[0])
sheets = UnwrapElement(IN[1])

Output = []

for sheet, revision in zip(sheets, revisions):
    revnum = [Autodesk.Revit.DB.ViewSheet.GetRevisionNumberOnSheet(sheet, rev.Id) for rev in revision]
    Output.append(revnum)

OUT = Output

```

Lambda:

```
import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

revisions = UnwrapElement(IN[0])
sheets = UnwrapElement(IN[1])

f = lambda sht, revi : [Autodesk.Revit.DB.ViewSheet.GetRevisionNumberOnSheet(sht, rev.Id) for rev in revi]

OUT = [f(sheet, revision) for sheet, revision in zip(sheets, revisions)]

```

Edit: removed unnecessary imports.

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [February 21, 2019, 9:59am UTC](https://forum.dynamobim.com/t/python-list-output/32444/7 "2019-02-21T09:59:55Z")

</div>

This is great stuff, it’s not really talked about too much in Python training, but it comes up so often for me!

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 21, 2019, 10:03am UTC](https://forum.dynamobim.com/t/python-list-output/32444/8 "2019-02-21T10:03:11Z")

</div>

Although @jacob.small would say it would be better to not make it iterate in a list, just use the simple `Autodesk.Revit.DB.ViewSheet.GetRevisionNumberOnSheet(UnwrapElement(IN[0]), UnwrapElement(IN[1]).Id)` in a python node, put it into a custom node where the inputs are regulated to a single item, and let levels and lacing do the work for you.

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 21, 2019, 10:06am UTC](https://forum.dynamobim.com/t/python-list-output/32444/9 "2019-02-21T10:06:44Z")

</div>

Adding a third option since I just learned about map + lambda 🤣

```
import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

revisions = UnwrapElement(IN[0])
sheets = UnwrapElement(IN[1])

f = lambda sht, revi : [Autodesk.Revit.DB.ViewSheet.GetRevisionNumberOnSheet(sht, rev.Id) for rev in revi]

OUT = map(f, sheets, revisions)
```

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [February 21, 2019, 10:11am UTC](https://forum.dynamobim.com/t/python-list-output/32444/10 "2019-02-21T10:11:11Z")

</div>

Just out of courisity  
Would it make a difference if Revisions in Revit is set per Sheet / per Project?  
Would it make a difference if there where dependant views with the revisions clouds on the Views?  
Would it make a difference if Revision Clouds are on the Sheets?

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [February 21, 2019, 10:14am UTC](https://forum.dynamobim.com/t/python-list-output/32444/11 "2019-02-21T10:14:58Z")

</div>

I have no clue 😂 I don’t have much if any experience with revisions so I don’t know the behavior. I would have to test it out.

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [February 21, 2019, 10:17am UTC](https://forum.dynamobim.com/t/python-list-output/32444/12 "2019-02-21T10:17:44Z")

</div>

Hi Marcel,

Yes it is different if you set the Revisions By Project…

[http://www.revitapidocs.com/2018/f46d2d49-1d37-6e99-f450-d21401fd848f.htm](http://www.revitapidocs.com/2018/f46d2d49-1d37-6e99-f450-d21401fd848f.htm)

You’ll see the method I’ve used in the Remarks…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/b/4bc51ccebf6b4347e7e592ec659d1ece2756fce0.png)

I suspect that you can pull other info from Revision clouds, but I always have a Revision ticked in ‘Revisions on Sheet’ incase (when) someone deletes the cloud.

I would never put revisions on views incase (when) they get clipped and/or accidently copied from view to view.

Cheers,

Mark

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [February 21, 2019, 10:18am UTC](https://forum.dynamobim.com/t/python-list-output/32444/13 "2019-02-21T10:18:42Z")

</div>

@kennyb6 Lambda’s scare the sh\*t out of me 😃

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [February 21, 2019, 10:22am UTC](https://forum.dynamobim.com/t/python-list-output/32444/14 "2019-02-21T10:22:27Z")

</div>

I was just wondering if the setup of Revisions would affect the Revision Matrix mentioned in this thread.

> [@Revision Tracking for Revit Sheets](https://forum.dynamobim.com/t/revision-tracking-for-revit-sheets/32290):
>
> Hello everyone, I was able to Track Revisions on my sheets by assigning the revisions to a project parameter. (The idea for this graphic was thanks to [Sheet List with Revision Matrix](https://forum.dynamobim.com/t/sheet-list-with-revision-matrix/21858)) The graphic works great; however, it involves human error because we have to run the dynamo every time we add a new revision. Is there a way to have these values set up from dynamo and not from the user end? so that eveytime we run the dynamo, it only updates the parameters already assigned. Thank you in advance!…

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [February 21, 2019, 10:25am UTC](https://forum.dynamobim.com/t/python-list-output/32444/15 "2019-02-21T10:25:17Z")

</div>

Hey, yes it would, but from a personal point of view it is a solid workflow.

Other people might have different workflows 😃

I think the major problem is the need for a custom parameter everytime you have a new revision. You’d want to add an auto parameter create as part of the graph and I don’t know how Revit would respond to having 2000 shared parameters in the sheet properties. I guess the OP will find out 🙂

Cheers,

Mark

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [February 21, 2019, 10:35am UTC](https://forum.dynamobim.com/t/python-list-output/32444/16 "2019-02-21T10:35:19Z")

</div>

I use a Revision Schedule in my TitleBlock, so, no need for extra parameters.  
I would fire every teammember that needs 20 revisions to get it right 🙂

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [February 21, 2019, 10:39am UTC](https://forum.dynamobim.com/t/python-list-output/32444/17 "2019-02-21T10:39:56Z")

</div>

This was to create a Drawing Issue Register… So you can pull every issue from every drawing and put it in a single place. This kind of thing…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/2/9265c96da3db2209d12d27f20b9d7c42a78c4d94.png)

I would generate an Excel, but the OP wanted it entirely in Revit and as a Parameter… Hence the need for a parameter to match every revision… Then the dynamo populates the parameters correctly.

Over the course of (5 years?) a GA plan might get issued 30 times… I wouldn’t sack someone personally, but I can see how it would focus your employees on early coordination and getting it right! 😛

Cheers,

Mark
