# Schedulefilter.FieldId

**URL:** <https://forum.dynamobim.com/t/schedulefilter-fieldid/71171>\
**Category:** Revit\
**Tags:** revit, dynamo\
**Created:** [December 7, 2021, 7:39pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171 "2021-12-07T19:39:53Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanCloet](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JanCloet](https://forum.dynamobim.com/u/JanCloet)\
**Post date:** [December 7, 2021, 7:39pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/1 "2021-12-07T19:39:53Z")

</div>

I’m trying to collect the filtering on schedules by the standard nodes.  
The node **Schedulefilter.FieldId** does not seem to work properly.

As you can see on the image The field numbers do not match the fields index number, but they do match the fields in revit ofcourse.

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

The only thing I can Imagine is that somewhere the lists went corrupt by being thrown from project to project … +2000  
The amount of project parameters available on this particular document is imense though …

Someone please help me. I’m new and try to use as much standard nodes as possible to get going.

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [December 7, 2021, 9:20pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/2 "2021-12-07T21:20:24Z")

</div>

It is because at some point (when the filter was applied) there were values in the schedule. As fields are removed, the ID of the filter stays.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/c/7c8f433e2c40845d36bf9a591964a71944c5a1e3.png)

---

<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:** [December 7, 2021, 9:33pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/3 "2021-12-07T21:33:49Z")

</div>

`FieldId` does not relate to index or column position. It’s just an identifier based on how many parameters have been added to the schedule. In fact, if you add Param1 and Param2 to your schedule as Ids 0 and 1, if you removed and re-added Param2, it would actually get a new Id of 3.

---

<div class="post-metadata">

**Author:** ![JanCloet](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JanCloet](https://forum.dynamobim.com/u/JanCloet)\
**Post date:** [December 7, 2021, 9:48pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/4 "2021-12-07T21:48:04Z")

</div>

Ok. So the message will be to dig into the API and fetch some usefull parameters compared to thos guy. Can i collect the code behind a standard node to start from here?

> ![](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.dynamobim.com/nick_boyts/45/76313_2.png "Nick\_Boyts") | [Nick\_Boyts](https://forum.dynamobim.com/u/nick_boyts) Regular  
> December 7 |
> 
> - | - |

`FieldId` does not relate to index or column position. It’s just an identifier based on how many parameters have been added to the schedule. In fact, if you add Param1 and Param2 to your schedule as Ids 0 and 1, if you removed and re-added Param2, it would actually get a new Id of 3.

---

<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:** [December 7, 2021, 9:55pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/5 "2021-12-07T21:55:17Z")

</div>

You cannot access the code in a standard node. I’d start with the API member for ScheduleFilters.  
[https://www.revitapidocs.com/2020/2c2fc999-859e-169b-d958-ee248d9d74b7.htm](https://www.revitapidocs.com/2020/2c2fc999-859e-169b-d958-ee248d9d74b7.htm)

---

<div class="post-metadata">

**Author:** ![JanCloet](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JanCloet](https://forum.dynamobim.com/u/JanCloet)\
**Post date:** [December 7, 2021, 10:19pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/6 "2021-12-07T22:19:00Z")

</div>

That’s what I meant. But there’s a code behind a node, right? I’ll dog into it further. Thx for the reply

> ![](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.dynamobim.com/nick_boyts/45/76313_2.png "Nick\_Boyts") | [Nick\_Boyts](https://forum.dynamobim.com/u/nick_boyts) Regular  
> December 7 |
> 
> - | - |

You cannot access the code in a standard node. I’d start with the API member for ScheduleFilters.  
[https://www.revitapidocs.com/2020/2c2fc999-859e-169b-d958-ee248d9d74b7.htm](https://www.revitapidocs.com/2020/2c2fc999-859e-169b-d958-ee248d9d74b7.htm)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [December 7, 2021, 10:24pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/7 "2021-12-07T22:24:47Z")

</div>

Not really sure why, but I was not able to get the DB element from the Fields Node and therefore none of the Methods or properties I tried to get after was working. @solamour

I ended up doing all of it in python to get the Name, Field Id, and Field Index for the values in a schedule. With these things you should be able to get the relationship you are after.

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

[schedule fields.dyn](https://forum.dynamobim.com/uploads/short-url/aZLmbTNUMDIUd1rMnDCJ0JOBFcR.dyn) (19.4 KB)

---

<div class="post-metadata">

**Author:** ![JanCloet](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JanCloet](https://forum.dynamobim.com/u/JanCloet)\
**Post date:** [December 8, 2021, 12:08pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/8 "2021-12-08T12:08:46Z")

</div>

I need this to work on all of my schedules at once.  
Input for this schedul

So in fact I need a list of my listed schedules and not from 1 index.  
How do I embed this in a Python script?

I’ve tried the following:

1. change UnwrapElement to UnwrapElement **s**
2. try to create a map on the output map(elements (but the script seems to only take 1 index as an input, really)
3. in the OUT I tried to state element, element,[f.FieldId for f in fields], but also only works on 1 element.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/1/1115607e4d60cfb548911ce3727e0ca0a5c7a9c2.png)

I guess this is something basic I don’t understand about coding and you encounter a lot if you do so.

Hope someone can help me here just as quickly!

---

<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:** [December 8, 2021, 2:55pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/9 "2021-12-08T14:55:07Z")

</div>

You have to loop through each schedule individually as an input and as its collected output(s).

For one schedule:

```auto
schedule = UnwrapElement(IN[0])
     *do stuff to schedule*
OUT = *schedule output*

```

For multiple schedules:

```auto
schedules = UnwrapElement(IN[0])
output = []
for schedule in schedules:
     *do stuff to schedule*
     output.append(*schedule outputs*)
OUT = output

```

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [December 8, 2021, 9:08pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/10 "2021-12-08T21:08:02Z")

</div>

> [@SeanP](#):
>
> Not really sure why, but I was not able to get the DB element from the Fields Node and therefore none of the Methods or properties I tried to get after was working.

Hi,  
as `DB.ScheduleField` doesn’t inherit from `DB.Element` I don’t think `UnwrapElement()` is useful  
I found 2 solutions in this particular case

- using the property `Name` of `Revit.Schedules.ScheduleField`

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

- using the internal property ‘InternalScheduleField’ of ‘Revit.Schedules.ScheduleField’ to get `DB.ScheduleField` object with Reflection, then using `GetName()`  
_It’s not ideal, but it’s a solution_

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

```auto
import sys
import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("System.Reflection")
from System.Reflection import BindingFlags

lstscheduleField = IN[0]
e = lstscheduleField[0]
invokeObj = clr.GetClrType(e.GetType()).InvokeMember('InternalScheduleField', 
                                                    BindingFlags.InvokeMethod | \
                                                    BindingFlags.GetProperty | \
                                                    BindingFlags.Instance | \
                                                    BindingFlags.Public | \
                                                    BindingFlags.NonPublic, 
                                                    None, 
                                                    e, 
                                                    None)
OUT = invokeObj.GetType(), invokeObj.GetName()

```

---

<div class="post-metadata">

**Author:** ![JanCloet](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JanCloet](https://forum.dynamobim.com/u/JanCloet)\
**Post date:** [December 8, 2021, 9:11pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/11 "2021-12-08T21:11:52Z")

</div>

Hi Nick,  
I made this out of your answer. Have been searching for quite some time to see the logic but maybe I need basic coding insight 😑

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

```auto
#Preparing input from dynamo to revit
items = UnwrapElement(IN[0])
element = UnwrapElement(items)

#Do some action in a Transaction
output = []
	for element in items:
		TransactionManager.Instance.EnsureInTransaction(doc)
		order = element.Definition.GetFieldOrder()
		fields = [element.Definition.GetField(o) for o in order]
		TransactionManager.Instance.TransactionTaskDone()
	output.append([f.FieldId for f in fields])

OUT = output

```

---

<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:** [December 8, 2021, 9:25pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/12 "2021-12-08T21:25:51Z")

</div>

As the error says, you have an unnecessary indent. You only indent what’s _inside_ the loop, so you don’t need to indent the `for element in items:` line.

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [December 8, 2021, 9:33pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/13 "2021-12-08T21:33:43Z")

</div>

Thanks for the informatoin @c.poupin, great work as always!  
I think i would rather just use a quick filtered element collector and avoid the issue. 😃

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [December 8, 2021, 9:44pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/14 "2021-12-08T21:44:24Z")

</div>

Here is how you can get what you are after

```auto
#Sean Page
#https://www.linkedin.com/in/sean-page-aia-ncarb-leed-ap-b06b0041/
#2021
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
schedules = UnwrapElement(IN[0])
fieldIds = []
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for schedule in schedules:
    order = schedule.Definition.GetFieldOrder()
    fields = [schedule.Definition.GetField(o) for o in order]
    fieldIds.append([f.FieldId for f in fields])

TransactionManager.Instance.TransactionTaskDone()

OUT = fieldIds

```

 ![schedule fields_2021-12-08_03-43-02](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/5/e5942a6b1bc497596c76645c5a18856fe20d2539.png)

---

<div class="post-metadata">

**Author:** ![JanCloet](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JanCloet](https://forum.dynamobim.com/u/JanCloet)\
**Post date:** [December 8, 2021, 9:48pm UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/15 "2021-12-08T21:48:08Z")

</div>

Not by far what it needs to be.  
I expect a list with sublists instead of a list on 1 element as in FieldID in the image.

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

Still Thanks for looking at this thread!

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [December 9, 2021, 1:40am UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/16 "2021-12-09T01:40:49Z")

</div>

Look at my response. The output.append line needs to be indented. Right now your only getting a list of the last schedule, not a list of lists.

> [@SeanP](#):
>
> ```auto
> for schedule in schedules:
> order = schedule.Definition.GetFieldOrder()
> fields = [schedule.Definition.GetField(o) for o in order]
> fieldIds.append([f.FieldId for f in fields])
> 
> ```

---

<div class="post-metadata">

**Author:** ![JanCloet](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@JanCloet](https://forum.dynamobim.com/u/JanCloet)\
**Post date:** [December 9, 2021, 6:07am UTC](https://forum.dynamobim.com/t/schedulefilter-fieldid/71171/17 "2021-12-09T06:07:34Z")

</div>

Thanks guys!
