Start dynamo script from excel

Hi,
Is it possible to send a command/signal from excel (vba) to tell dynamo to start or to continue a script ?

1 Like

Seems like it would be best to create two separate graphs. You could run them from Dynamo Player that way.

Not totally sure it would work:

You’d have to run the script from Dynamo Player, close Player, make changes and save, then run second script from Player. It’s not the most elegant method but I think it would still work.

The image doesn’t show node names so I can’t tell what’s going on in the script, but it’s possible you could keep it as two separate functions within the same graph. Just have boolean toggles before each function that determine whether that specific part gets executed or not. (I guess really it could be a single toggle for both.) So you could have Part 1 set to True when you run it the first time, make your changes in Excel, save, and close, then toggle Part 1 to False and Part 2 to True and run the script again so that Part 2 gets executed this time. Just a thought…

Just an idea also, you could maybe try to read a specific cell just before a Passthrough node (Clockwork).

Thanks Yna.
I just thought of that too. But dynamo has to keep watching my excel file for that specific cell to change.
But it might work. I’ll let you know.

Running a second script after changing and saving the excel file is something I want to prevent.

I love this idea…this would be amazing…control Dynamo for VBA! :grinning:

1 Like

@erfajo This trick works well indeed :slightly_smiling_face:
@d.kelfkens I did not manage to read a specific cell with ReadExcel.ByRange (I can not make it work anymore, I don’t know why) but I was looking for a solution to make the graph wait until I give an additional input and I succeeded with Springs.Filter.BySelection just before the passthrough, because it generates a popup. This could be a first workaround.

Here could be another solution for a popup but I did not try it yet:

Is it possible to make a python script detect an active workbook/sheet (not opening a new one) and check a certain cell value for a change (a switch 0/1) using a loop? After changing from 0 to 1 the script imports all data from the sheet.

I believe that excel nodes update every time the file is saved by something other than dynamo.

I noticed that. That is just what I’m trying to prevent.
It has to update after I finished entering data.

This script makes dynamo / revit crash.

Ah…It has to be this : cell = worksheet.Range[“A1”].Text

Now dynamo doesn’t crash and I’m getting the cell value from the active sheet.
Next thing is the “waitfor” trick to get it to work.

1 Like

Looks like that isn’t necessarily true (though that’s what I expected as well).
If you use a boolean to toggle when the second part gets run you can get the Excel data after it’s been edited.


As you can see, I originally sent the data with all values as “Unknown” and the read portion toggled to False. The Excel file was created and opened, I edited some values, did NOT save, and toggled the run portion to True and Dynamo read the updated unsaved data from the same file.

1 Like

Now we’re getting somewhere. Thanks everybody !!

The issue I encountered with the passthrough is that it seems to let the data pass as soon as the “wait for” function has ran, whatever the result is. I thought that at least with a popup, there would be no issue of that kind

Yes, I did it that way too, but it let my data (a string for the file path) pass in all cases (even with a null value as a result in the function that is to wait for).

I might be getting confused at this point, but wouldn’t an If node be more effective than a Wait or PassThrough? Doesn’t Wait just look for any value to continue? Wouldn’t it make more sense to use If to look for a specific output/toggle?

This seems to work really simply indeed :slight_smile:

I guess my question is are you trying to avoid interaction with Dynamo or any interaction at all? You could have an If node check the value of a specific cell so it would automatically continue once you say you’re finished. Still requires an input, but it’s all in Excel.