Call external python/CMD from within Grasshopper


sorry if this has been asked before – but I could find any working solution.

Is it possible to call a external script, (python or .bat) form within Grasshopper? Ideally while passing arguments and output of the script.




You should be able to use in a Python component to do this…

With Python this could involve saving your inputs as a text file or building a command line interface, eg using argparse or a CPython package such as click .

thanks graham, i will try;

also I found “Dodo: run executable”; but when I input the path to my python directory and the path to the python script as an argument nothing happens.

Hi Graham,

I tried

import subprocess

path_programm = "C:\\Users\\charlieNagamoto\\Documents\\test\\emptyFile.bat"[path_programm])

inside a GHpython node, sadly the bat file isn’t executed
Could you help?

what also could work is the following inside a vb node:

Dim path As String
path = (System.Environment.GetFolderPath(System.Environment.SpecialFolder.System)) & "\cmd.exe"
Dim proc As System.Diagnostics.Process = System.Diagnostics.Process.Start(path)

it opens the CMD but I can not figure out how to pass arguments to it. Does anyone know?

Search for subprocess.Popen. You can use stdin to pass the arguments and use stdout to get the output. You will see in the documentation how to redirect the stdout to PIPE.


Thanks Mostapha, This helps! I think I am on the right track

1 Like

if anyone in the future is searching for this:
Here is what I came up with; use at own risk; (4.1 KB)

1 Like

This worked fine. The only problem was that I had to give the absolute path to python.exe.