# Export schedule columns to Python array

**URL:** <https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705>\
**Category:** Developers\
**Tags:** python, schedule, dynamo\
**Created:** [April 4, 2018, 1:36pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705 "2018-04-04T13:36:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 1:36pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/1 "2018-04-04T13:36:08Z")

</div>

Hi there, it is me again.

I am currently working on the automation of Revit schedules export by using Dynamo and Python.  
The aim of this is to generate a list of quantities based on the famillies used in Revit.

I would like to transfer each column of the schedule to a specific Pyhon arrays.  
Those arrays will be processed later in Python to count different quantities.

I hope my explanation is clear enough.  
And thanks for your help.

Regars,  
Clement

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [April 4, 2018, 1:40pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/2 "2018-04-04T13:40:49Z")

</div>

It’s certainly possible; the big question is: on what basis do you want to split the data?

> [@Clement](#):
>
> using Dynamo and Python.

Just to make sure, I assume you mean using Python within Dynamo with that.

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 1:47pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/3 "2018-04-04T13:47:46Z")

</div>

My schedules would be formatted with a standard procedure it will result in a certain number of columns.  
Those columns should be transformed in a python array.

You are right, it would be a Python script inside Dynamo.

Maybe the best way is the cut this process in two parts.  
The first one would “parse” the schedule and have the arrays as output variables.  
The second would search those arrays for matching results, calculate the quantities based famillies and finally export to a existing Excel file (on a second sheet).

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [April 4, 2018, 1:49pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/4 "2018-04-04T13:49:43Z")

</div>

> [@Clement](#):
>
> he first one would “parse” the schedule and have the arrays in output variables.
> 
> The second would search those array for matching results, calculate the quantities based famillies and finally export to a existing Excel file (on a second sheet).

Yes. But do you have a list of names or something on which basis you’d want to split it?

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 1:52pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/5 "2018-04-04T13:52:29Z")

</div>

I don’t really understand what you mean 😕

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [April 4, 2018, 1:54pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/6 "2018-04-04T13:54:06Z")

</div>

You’re importing lists of data right?  
Is one of those which contains strings like “length”/“width”/“pressure” or parameter names or something alike.

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 4, 2018, 1:55pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/7 "2018-04-04T13:55:04Z")

</div>

Maybe if you show a sample of what you currently have it will be easier to assist you? 🙂

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 2:05pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/8 "2018-04-04T14:05:58Z")

</div>

Well, currently I don’t have much to show yet.

I am still trying to simply read the current schedule and export in Excel based [Read data in Pre-created schedule in Revit](https://forum.dynamobim.com/t/read-data-in-pre-created-schedule-in-revit/6245/5). Unfortunately, this alread fails…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/8/08db9f41075b920e07eb3a20aa0b25f5f2b8500e.png)

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [April 4, 2018, 2:07pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/9 "2018-04-04T14:07:12Z")

</div>

I think what you’re giving as input is more interesting.

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 2:15pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/10 "2018-04-04T14:15:00Z")

</div>

Added some more Watch nodes.  
The python script is from the topics linked in my post above.

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

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 2:18pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/11 "2018-04-04T14:18:40Z")

</div>

Well… the Code Block node is mandatory.  
That part is fixed.

But fails when trying to use the active view of the document

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/0/f0ebcfe05d4eb280f2c1a9f7d6468de48c140e81.png)

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 4, 2018, 2:26pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/12 "2018-04-04T14:26:57Z")

</div>

If I look at the link you provided I’d say you should attempt to pass “Document.Activeview” into the codeblock and see what happens.

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 2:32pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/13 "2018-04-04T14:32:12Z")

</div>

@Jonathan.Olesen thanks for the hint but unfortunately this does not work neither.

The output of ScheduleField.Name is correct “Nomenclature des canalisations” but the input of the code block is completly wrong. It seems that it only kept the first char of the complete string “N”…

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 4, 2018, 2:41pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/14 "2018-04-04T14:41:53Z")

</div>

Little-bit different approach:

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

I believe your issue is that you, while you are getting your schedule name, your not getting the “object” itself. Thus you cannot use python to “export” attributes from the object, which your code does.

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 3:27pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/15 "2018-04-04T15:27:46Z")

</div>

Well, the node schedules on sheets only list the schedule which are used in a sheet.  
What I want to do is, user opens a schedule then click the script button which will work on the active schedule.

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 4, 2018, 3:35pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/16 "2018-04-04T15:35:06Z")

</div>

How about this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/1/516c75cba14f1d62a58e3c218f88420416eaf906.png)

What makes you think that the code block is mandatory? When I look in your link the code block is used to choose the first of the schedules from the “Get All Views” node.

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 4, 2018, 3:40pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/17 "2018-04-04T15:40:36Z")

</div>

Document.ActiveViewFromCurrentDocument returns null 😕

---

<div class="post-metadata">

**Author:** ![Jonathan.Olesen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jonathan.olesen/32/44242_2.png) [@Jonathan.Olesen](https://forum.dynamobim.com/u/Jonathan.Olesen)\
**Post date:** [April 4, 2018, 3:41pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/18 "2018-04-04T15:41:01Z")

</div>

Try a restart of your system 🙂

---

<div class="post-metadata">

**Author:** ![Clement](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@Clement](https://forum.dynamobim.com/u/Clement)\
**Post date:** [April 5, 2018, 12:54pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/19 "2018-04-05T12:54:29Z")

</div>

A restart was indeed needed.

I reviewed the way I will process the data.  
I will export all I need in a Excel document.  
Do you know how to write the data on the same sheet using Write To Excel?

Thanks.

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [April 5, 2018, 1:01pm UTC](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705/20 "2018-04-05T13:01:34Z")

</div>

Considering your original question was answered, please mark the comment that solved it as solution so others with similar problems might be able (and maybe leave a like here and there).  
If you want to know how to send calculated data towards excel I think it’s better to create a new topic for that to keep the forum tidy.

[Next page](https://forum.dynamobim.com/t/export-schedule-columns-to-python-array/20705.md?page=2)
