# How to get Schedule Fields?

**URL:** <https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082>\
**Category:** Developers\
**Tags:** python\
**Created:** [September 25, 2017, 11:51am UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082 "2017-09-25T11:51:22Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![interactiverendering](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@interactiverendering](https://forum.dynamobim.com/u/interactiverendering)\
**Post date:** [September 25, 2017, 11:51am UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/1 "2017-09-25T11:51:22Z")

</div>

hi All new to Python and no experience at all but im trying to Get Scheduled Fields through python but im not really sure what im doing …Thanks for your help.!

Capture2|136x194

```auto
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

_keySchedule = UnwrapElement(IN[0])

OUT = ScheduleField

```

---

<div class="post-metadata">

**Author:** ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)\
**Post date:** [September 25, 2017, 2:30pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/2 "2017-09-25T14:30:06Z")

</div>

Are you just trying to get the list of parameters that are scheduled fields in a particular schedule? If so, you can use the OTB node ScheduleView.Fields and input your schedule view into that

---

<div class="post-metadata">

**Author:** ![interactiverendering](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@interactiverendering](https://forum.dynamobim.com/u/interactiverendering)\
**Post date:** [September 25, 2017, 4:34pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/4 "2017-09-25T16:34:44Z")

</div>

Hi thanks for quick response I’ll have to check, is that available using 1.2 version?

---

<div class="post-metadata">

**Author:** ![interactiverendering](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@interactiverendering](https://forum.dynamobim.com/u/interactiverendering)\
**Post date:** [September 25, 2017, 4:38pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/5 "2017-09-25T16:38:21Z")

</div>

I’m looking at the parameters (fields) that is in particular schedule.

I’m actually trying to look at API but my lack of knowledge translating it into python is driving me crazy 😂

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 25, 2017, 6:00pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/6 "2017-09-25T18:00:32Z")

</div>

Sorry, that first link I sent was for the wrong thing. This should be a good starting place: [http://www.revitapidocs.com/2018/fe88f8dc-4926-4ff4-4490-7aee58d5a3f4.htm](http://www.revitapidocs.com/2018/fe88f8dc-4926-4ff4-4490-7aee58d5a3f4.htm)

The nice thing about Python is it doesn’t require a lot of “translating” just simplification. I’m still fairly new to Python and coding in general but it’s not difficult to learn. All the methods and properties you need to get the parameters in your schedule are pretty straight forward. I suggest attempting this one member at a time. Get the schedule definition. Get the parameter Ids in the schedule. Convert the Ids to parameters. Then get the parameter names. Start writing out some code and see where it gets you. If you get stuck, post back here with your code and we can work it out.

---

<div class="post-metadata">

**Author:** ![interactiverendering](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@interactiverendering](https://forum.dynamobim.com/u/interactiverendering)\
**Post date:** [September 25, 2017, 7:28pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/7 "2017-09-25T19:28:21Z")

</div>

hi Nick i think im stuck now. 😕 dont know what to do next

import clr  
clr.AddReference(‘ProtoGeometry’)  
from Autodesk.DesignScript.Geometry import \*  
Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)  
import RevitServices  
from RevitServices.Persistence import DocumentManager  
from RevitServices.Transactions import TransactionManager  
Import RevitAPI

clr.AddReference(“RevitAPI”)  
import Autodesk  
from Autodesk.Revit.DB import \*

doc = DocumentManager.Instance.CurrentDBDocument  
uiapp = DocumentManager.Instance.CurrentUIApplication  
app = uiapp.Application

from System.Collections.Generic import \*  
Import ToDSType(bool) extension method

clr.AddReference(“RevitNodes”)  
import Revit  
clr.ImportExtensions(Revit.Elements)

#The inputs to this node will be stored as a list in the IN variable.  
dataEnteringNode = IN

sschedule = UnwrapElement(IN[0])

def getField(schedule, name):  
definition = schedule.Definition  
count = definition.GetFieldCount()  
for i in range(0, count, 1):  
if definition.GetField(i).GetName() == name:  
field = definition.GetField(i)  
return field

#“Start” the transaction  
TransactionManager.Instance.EnsureInTransaction(doc)

```
	scheduleField = getField(sschedule, i)

```

# “End” the transaction

TransactionManager.Instance.TransactionTaskDone()

OUT = scheduleField

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 25, 2017, 7:43pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/8 "2017-09-25T19:43:50Z")

</div>

Could you try reposting your code using the preformatted text option? Just select all your code and click the `</>` button in the toolbar above.

---

<div class="post-metadata">

**Author:** ![interactiverendering](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@interactiverendering](https://forum.dynamobim.com/u/interactiverendering)\
**Post date:** [September 25, 2017, 7:45pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/9 "2017-09-25T19:45:52Z")

</div>

```
    import clr
    clr.AddReference(‘ProtoGeometry’)
    from Autodesk.DesignScript.Geometry import *
    Import DocumentManager and TransactionManager

    clr.AddReference(“RevitServices”)
    import RevitServices
    from RevitServices.Persistence import DocumentManager
    from RevitServices.Transactions import TransactionManager
    Import RevitAPI

    clr.AddReference(“RevitAPI”)
    import Autodesk
    from Autodesk.Revit.DB import *

    doc = DocumentManager.Instance.CurrentDBDocument
    uiapp = DocumentManager.Instance.CurrentUIApplication
    app = uiapp.Application

    from System.Collections.Generic import *
    Import ToDSType(bool) extension method

    clr.AddReference(“RevitNodes”)
    import Revit
    clr.ImportExtensions(Revit.Elements)

    #The inputs to this node will be stored as a list in the IN variable.
    dataEnteringNode = IN

    sschedule = UnwrapElement(IN[0])

    def getField(schedule, name):
    	definition = schedule.Definition
    	count = definition.GetFieldCount()
    	for i in range(0, count, 1):
    		if definition.GetField(i).GetName() == name:
    			field = definition.GetField(i)
    	return field
    	
    #"Start" the transaction
    TransactionManager.Instance.EnsureInTransaction(doc)

    		scheduleField = getField(sschedule, i)

    # "End" the transaction
    TransactionManager.Instance.TransactionTaskDone()

    OUT = scheduleField`
```

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 25, 2017, 9:37pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/10 "2017-09-25T21:37:40Z")

</div>

You have your input defined as `sschedule` but you call `schedule` in the definition line. You also have an `if` statement with no `else` line. I don’t think you need a transaction either since you’re just pulling data but it’s not going to hurt anything either.

Try something like this. It’ll return the parameters (names) for that schedule, which you can query for a specific parameter if you want.

```
keyschedule = UnwrapElement(IN[0])
definition = keyschedule.Definition
ids = definition.GetFieldOrder()
names = []

for id in ids:
	param = definition.GetField(id)
	names.append(param.GetName())
```

---

<div class="post-metadata">

**Author:** ![interactiverendering](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@interactiverendering](https://forum.dynamobim.com/u/interactiverendering)\
**Post date:** [September 26, 2017, 4:17am UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/11 "2017-09-26T04:17:20Z")

</div>

Thanks Nick I’ll try it later today. Cheers!

---

<div class="post-metadata">

**Author:** ![interactiverendering](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@interactiverendering](https://forum.dynamobim.com/u/interactiverendering)\
**Post date:** [September 26, 2017, 4:04pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/12 "2017-09-26T16:04:06Z")

</div>

thanks nick!

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [September 27, 2017, 2:58pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/13 "2017-09-27T14:58:57Z")

</div>

In my opinion that’s a better answer. @awilliams 👍

OOTB nodes support `SchedulableFields` and `Fields`. The former is a list of all Parameters that can be scheduled for the given category/schedule, while former is a list of currently added/being scheduled fields. Please use OOTB nodes as much as possible over Python - especially if you are just learning. There is no reason to add to the complexity by trying to learn Python + Revit API on top of Dynamo. I would only resort to Python when OOTB doesn’t support functionality.

---

<div class="post-metadata">

**Author:** ![interactiverendering](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@interactiverendering](https://forum.dynamobim.com/u/interactiverendering)\
**Post date:** [September 27, 2017, 3:05pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/14 "2017-09-27T15:05:24Z")

</div>

Thanks @Konrad_K_Sobon yeah I would its just in this case I cannot just upgrade into dynamo version 1.3 as the corporate standard didn’t release yet the latest one, so I have to find another way to work in my current project 🙂

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [September 27, 2017, 3:10pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/15 "2017-09-27T15:10:12Z")

</div>

Please make that clear when you are asking the question. Also, please make sure to format any code appropriately. I will fix that for now, but in the future you should do that yourself.

---

<div class="post-metadata">

**Author:** ![ruben.romero](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ruben.romero/32/115842_2.png) [@ruben.romero](https://forum.dynamobim.com/u/ruben.romero)\
**Post date:** [September 11, 2021, 3:02pm UTC](https://forum.dynamobim.com/t/how-to-get-schedule-fields/15082/16 "2021-09-11T15:02:35Z")

</div>

@Konrad_K_Sobon once you get schedule fields, how can I identify the parameters of that field names? I want to know more about the Fields, for example if those are type or instance parameters, project/family/shared/global/builtin parameters. I am creating new post to ask that question more specific. Thanks
