Dynamo Schedule Creation - Filter - no values

hi all!

I have a script that I have created that allows the creation of a schedule by a Room’s Number and the assigning of a Schedule Template. (This works, unfortunately one at a time, as I couldn’t figure our how to run a list through at the time, something I would like to change in the near future!)

I have since changed companies and I need to change one of my filters to :

“HasNoValve”

image

However the node seems to require a Value [var] input to perform the function… I cannot seem to find a node that will allow a filter to be created without a value being required.

Is there a node in a Package or a value that tells Revit/Dynamo, that no value is required?

Thanks

Try using a code block or string input with double quotations inputted in. You shouldn’t have to have a space between the quotation marks. But it that doesn’t work, then try with a space.

image

Thanks for the suggestion Staylor, however the filter still fails to create itself.

One thing I didn’t realize at first is that filter type does not require a value and the ScheduleFilter.ByFieldTypeAndValue node is not set up to handle those types of filters.

The post here should help resolve your issue. With this code you have to input the schedule and the name of the field. This automatically adds the filter to the schedule, so you don’t feed the output into the ScheduleView.AddFilters node.

You will also have to edit the part of the code circled. Change that to what you want your filter type to be after the period. “HasNoValue” or “HasValue”.

image

hi Staylor,

Thanks again for the response.

The linked conversation does seem to be the same as my problem, however the script is looking for a “View.Type” so does not seem to work in the same way as the node I am currently using?

I tried using it, providing the schedule view but I am still just getting a “Null” from this Python Node… is it set up to only work within an existing schedule? Not one that is being assembled?

*Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. *
Traceback (most recent call last):

  • File “”, line 24, in *
    AttributeError: ‘List[object]’ object has no attribute ‘ViewType’

Here is the script from the link, as you pointed out I edited out the parameter definition to be “HasValue”

Thanks again.

The code is setup to only handle one schedule at a time and not iterate through a list of schedules.
Change code to as shown below. Also as I previously stated, the code automatically applies the filter to the schedule and returns the scheduleview and not a view filter, so don’t feed the output into your list of elements that are going to the ScheduleView.AddFilters node. See last clip.

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

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

def fieldId(schDefinition, fieldName):
	OrderedFields = schDefinition.GetFieldOrder()
	for x,id in enumerate(OrderedFields):
		field = schDefinition.GetField(id)
		if field.GetName() == fieldName:
			return schDefinition.GetFieldId(x)
	return None       

schedule = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]

OUT = []

for s in schedule:
	if s.ViewType == ViewType.Schedule:
		definition = s.Definition
		field = fieldId(definition,IN[1])
			
		TransactionManager.Instance.EnsureInTransaction(doc)
			
		filter = ScheduleFilter(field, ScheduleFilterType.HasValue)
		definition.AddFilter(filter)		
			
		TransactionManager.Instance.TransactionTaskDone()		
		
OUT.append(schedule)

image

I guess after all said and done, you probably could have just used the “NotEqual” filtertype and then used the double quotations for the value. Should yield the same results as “HasValue”.

Hi Staylor,

Thanks again for the reply, for clarification the script is only creating an singular regular schedule. With the required input through the Dynamo Player being “Room Number”. So in my example, the room number is CBR-001. So it is not creating a list (or multiple) schedules.

I have amended as per your post but still getting an error. It seems odd to me that we have a Python Script that would not then feedback into the list node that then goes into the “ScheduleView.AddFilters” node?

Would this create a conflict and have one overwriting the other’s filter instruction for the schedule?

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 31, in
Exception: The input argument “fieldId” of function `anonymous-namespace’::ScheduleFilter_constructor or one item in the collection is null at line 82 of file D:\Ship\2021_px64\Source\Essentials\EssentialsDBAPI\gensrc\APIScheduleFilterProxy.cpp.
Parameter name: fieldId

Thanks again.

hi Staylor,

Thanks for this suggestion, this does work… However it requires the parameter to be present within the families they are filtering out. But it should be workable change. Thanks.

1 Like

Even though it’s one schedule being returned, it’s being returned as a list.
image

As far as that last error message, unfortunately I don’t have a clue what could be causing that, so hopefully someone else can provide input.

hi staylor,

Thank you for your efforts on this one! It has baffled us both it seems. Not sure about the list thing either, as the schedule creation node also put the schedule into a list…

image

So not sure what I could be doing differently to get the schedule element in none list form.