I was trying to use Matplotlib and other python modules from within Python nodes in Dynamo then I quickly recognized that it won’t work with IronPython. So I was thinking as a workaround to use a Dynamo Node to trigger an external file ( may be a .py or .exe file) to launch when the dynamo graph is run. Is there a way to accomplish this?
Have figured out a way using System.Diagnostics.Process. I will put it here in the case anyone finds it useful in the future
from System.Diagnostics import Process
path = r"C:\somepath"
myfile = "somefile.docx"
command = "%s\\%s"% (path,myfile)
proc = Process()
proc.StartInfo.FileName = command
proc.Start()
proc.WaitForExit()
7 Likes
Can I to load and to get values by parameters in this exe? How to make this?
For those who are not familiar with coding, can directly use the below Code in a Python Script Node.
The input (IN[0]) is just a simple File Path Node. Hope it can help.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System.Diagnostics import Process
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# Place your code below tis line
filepath = IN[0]
proc = Process()
proc.StartInfo.FileName = filepath
proc.Start()
proc.WaitForExit()
# Assign your output to the OUT variable.
OUT = 0
1 Like
To launch a PY file i would just save it as a .txt file type then read that in Dynamo and input it into the python node that has a “String” input.
Though it will have to follow the correct syntax.