How To Differentiate Timing Of Execution?

So I have a .DYN all set up to modify and then export a schedule from Revit to Excel.

I’m actually a little proud of it. When using the player, you type in the parameter value that you want to filter into the schedule. It actually applies a filter to the schedule that is specified by the user input. It names the Sheet with a description of the report and even has the current date as well. It has a dialog box that should pop up in the middle with a brief explanation of what the script does, and reminds the user to reset the filter before running the script again. (I haven’t added that in yet.)

But I am at a loss, because every time I run the script it does things backasswards. The schedule will be exported in full to Excel… and THEN it will apply the filter to the schedule.

import clr
from Autodesk.Revit.UI import *

sYs = IN[0]
SchedView = IN[1]

title = IN[0] + " System Quantity Report"

mainDialog = TaskDialog("Don't forget to reset the filter!")
mainDialog.MainInstruction = title
mainDialog.MainContent = """This script accomplishes two tasks:

1. Adjust the filter that is applied to the System Quantity Report Schedule's data to only include the defined System.

2. The resulting data will then be exported to an Excel Spreadsheet with the appropriate Sheet Name.

Don't forget to delete the resulting filter pertaining to the System Quantity Report Schedule in Revit, before you run this script again.

Thank you"""

#mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, sYs)
#mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Lets fuck some shit up fam")

#mainDialog.CommonButtons = TaskDialogCommonButtons.Close;
#mainDialog.DefaultButton = TaskDialogResult.Close;

#mainDialog.FooterText = "Click here for the Revit API Developer Center"

tResult = mainDialog.Show()
OUT = [tResult, IN[1]]

I’ll post the .DYN screenshot, but I just don’t know where to start fixing this. I just want a way to get the script to wait till after the dialog box has been closed by the user, and then export the schedule. Does anyone have any ideas on how I can make this happen?

Use a WaitFor method - Clockwork and several other packages have nodes which do this. Take any output from the ‘popup’ triggering node and create a list of it and the input triggers for the next step of the graph. In this case it could be the initial Revit element selection (though to be honest I can’t see what your graph is doing when as the wires are miles long and you have no notation, groups, or any documentation so I could be way off). Then pull the data you want to PSs along from the list. In a single line of design script it looks like this:

[popupResponse, dataToWaitForProcessing][1];

Give it a shot (and maybe add some notes, groups, and documentation to your graph while you’re at it), and let us know if you get stuck.


I’m not a Revit expert but should this graph also use a transaction.end node after the schedule modification?

1 Like

It could, but I believe that it is unnecessary here as the data should be updated as soon as the ‘set’ of the filters is applied, transaction or not.

First off, thank you for you’re suggestion. I apologize for the late response as I was on vacation.

However the WaitFor command does not seem to be working for me. I have it waiting for the dialog input from the Python script, and the Passthrough is the ScheduleView output from the end of the filter-setting part of the whole script. Did I set it up in the wrong order?

Is there a way to add the WaitFor command to the Python script maybe? I’ve noticed that there is quite a few seconds of difference between when the data is exported into Excel and when the changes are applied to the Revit Schedule. I’d love to add a button to the Python dialog popup that could maybe specify an output or something.