I am writing custom Python nodes within Dynamo and would like to leverage the ‘System.Threading.Tasks’ library to run parallel tasks to reduce compute time.
Does Python in Dynamo allow parallel tasks / multi-threading?
Hello Carlo,
I’m interested in reduce computing time using Dynamo too. Did you solve this?
Regards.
Take a look at Spring Nodes Mesh.ToPolySurface. It is multithreaded:
<Workspace Version="1.3.1.1736" X="-90.0987335424144" Y="171.830059122888" zoom="1.96524455617686" ScaleFactor="1" Name="Springs.Mesh.ToPolySurface" Description="Converts a Dynamo mesh to a polysurface. Uses multithreading - optimized for 4 cores." ID="098af804-e737-4150-82b8-ef3bafda7248" Category="Springs.Geometry">
<NamespaceResolutionMap />
<Elements>
<PythonNodeModels.PythonNode guid="774a37af-9038-419d-81a1-d74c0608d122" type="PythonNodeModels.PythonNode" nickname="Python Script" x="250" y="0" isVisible="true" isUpstreamVisible="true" lacing="Disabled" isSelectedInput="False" IsFrozen="false" isPinned="false" inputcount="2">
<PortInfo index="0" default="False" />
<PortInfo index="1" default="False" />
<Script>#Copyright(c) 2016, Dimitar Venkov
# @5devene, dimitar.ven@gmail.com
import clr
from System.Threading import Thread, ThreadStart
from operator import itemgetter
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
def tolist(obj1):
if hasattr(obj1,'__iter__'): return obj1
else: return [obj1]
def chop1(l1, n):
This file has been truncated. show original
5 Likes
Thanks @Einar_Raknes , nice contribution!