Automating tyParticleController assignment via Python
#1
I have a set of objects that I am using in my sim that I wanted to track using objects in my scene and tie them with tyParticleControllers

To make it easy I just used an export of the Particles from tyFLow.

I wanted to share my code for connecting those new objects with the particles they represented with a tyParticleController...

This only works with one event.  So you would have to tweak it to work with multiple events.

Code:
from pymxs import runtime as pyMX

# tyFlow name to get the node
tyFlowName = 'tyFlow_Tentacle'

# tyFlow Prefix for exported nodes
exportNodesPrefix = 'tyFlow_node_'

sceneTyFlow = pyMX.GetNodeByName(tyFlowName)
partList = list(sceneTyFlow.Tentacles.Birth_Objects.shape_list)

numParticles = len(partList)

exportNodes = list(pyMX.readvalue(pyMX.StringStream('$' + exportNodesPrefix + '*')))

for x in range(0,numParticles):
   partNode = partList[x]
   exportNode = exportNodes[x]
   
   tyCtrl = pyMX.setProperty(pyMX.getSubAnim(exportNode, 3), 'controller', pyMX.tyParticleController())
   tyCtrl.flow = sceneTyFlow
   tyCtrl.indexIsID = True
   tyCtrl.particleID = x
  Reply


Forum Jump: