If for some reason you don’t want to plug your particle system directly into your MASH network you can get particle positions via the Python node like this.
You’ll need to edit the name of the particle system in the Python script, but other then that, you can just copy and paste this script into the Python node in order to use it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import openMASH #initialise the MASH network data md = openMASH.MASHData(thisNode) #storage for the particle positions ppositions = [] try: #this will fail if the particle count is zero ppositions = cmds.getAttr('nParticleShape1.worldPosition') md.setPointCount(len(ppositions)) except: md.setPointCount(0) #and this gets the number of objects in the network count = md.count() #set the MASH position to the particle position for i in range(count): md.outPosition[i].x=ppositions[i][0] md.outPosition[i].y=ppositions[i][1] md.outPosition[i].z=ppositions[i][2] #tell MASH to write the network data md.setData() |