How to launch Dynamo automatically (Revit macro)

Hi guys!
I’m trying to create a Revit macro in c# for launching Dynamo at the Revit startup. Is it possible?
I’m aware of dynamo automation, dynamo sandbox and other related topics, but I can’t find a solution for this particular task.
Any suggestion?

Hi!

I have managed to launch a Dynamo Player with a postable command, like so:

public void postable() {
			
		UIApplication uiapp = this.ActiveUIDocument.Application;
            RevitCommandId cmdId = RevitCommandId.LookupCommandId("ID_PLAYLIST_DYNAMO");
            uiapp.PostCommand(cmdId);   
}

In theory you should be able to launch standard dynamo with a “ID_VISUAL_PROGRAMMING_DYNAMO” command name, but I am getting an error. My journal files are showing that this command is replaced by a Dynamo version selector, due to 1.3 and 2.0 installed - maybe that is the reason. Or maybe the command name should be something different.

Maybe it will work for you or guide you in a right direction…

For me, I uninstall Dynamo 1.3 for Revit on our machines It creates issues with Dynamo player. I only use 2.

Hi @maciek.glowka! Thanks for your reply! Very helpful, but I still have 2 issues.

  1. “ID_VISUAL_PROGRAMMING_DYNAMO” is giving me error as well but I noticed that the Dynamo version selector is also present with “ID_PLAYLIST_DYNAMO” in my journal file.
    So maybe the problem is with “ID_VISUAL_PROGRAMMING_DYNAMO”… not sure…
  2. Another issue I notice is that it doesn’t run the macro at the startup.
    As far as I’ve understood, if I place the postable() command inside the public void Module_Startup(object sender, EventArgs e), it should run automatically at the startup, but it doesn’t… to run it I have to build it first and then close the macro manager… and then it works.

Do you have any idea how to solve them? Meanwhile I will try something with python instead… hopefully with more luck!

Hi,

there is a similar discussion here (although about starting from journals) but it seems that two Dynamo versions might be a problem:

Have you tried uninstalling one of the versions?

Another solution I have thought of would be to assign a keyboard shortcut to the dynamo command (even manually in the UI) and then emulating those key presses by the script. Should be doable.

For the second part of your question I have unfortunately no experience with startup scripts, but have you tried it as a both application and document macro? There might be a difference.

The two versions of Dynamo is going to be an issue. You will have to spin up a VM or send out to a different machine that only has one version installed if you are on your production machine and need both installed.

When @DomE mentions using Module_Startup, I am curious (I spend time in Addin dev, not so much Macro dev), if the application and the document is ready to receive the command at the moment Module is called. Is there a way to inject a method before DocumentReady in a Macro environment? I don’t know the answer to that.

Lastly, it may not be a popular comment, but if you are already familiar with C, then why not create an addin that does whatever action you are after using C rather than Dynamo? Sure, I get it. Dynamo is the new kid on the street that all of the hipsters want to hang out with. Its got the rad clothes and the new sneakers. (In all seriousness) If you can do it in C, it will be more stable in the long run. IMO. I’m not hating on Dynamo, it is a tool that has its use case. But, when attempting to do batch things like this, it may not be the best tool in your toolbox.