On 16/05/2015 at 21:04, xxxxxxxx wrote:
Alright. So I've edited the default code to work when there's an "Index" out port, but it gives an error each frame because 'Index' is expected to be an integer, not None. I'm just ignoring it for now and moving on. Here's the code:
Edit:
It still gets weird when particles stop emitting on 'count' emmisions but 'rate' seems to work fine.
To use multiple pgroups, you'll need to make a new channel, and it will get messed up when you try to get some data from a particle because the actual index remains unchanged. Working on it now 
______________________
import c4d
#Welcome to the world of Python
#This script gives each particle an unique ID
#so we can always identify the particle
#and give it always the same shape
#the UID counter
count = 0
data_channel_id = None
def GetUIDChannelID(tp) :
"""
Returns the index of a data channel
called 'Index(Integer)' or None.
:return: The index or None if failed
"""
global data_channel_id
if data_channel_id!=None:
return data_channel_id
#lets browse the data channels and
#lets look for the name
name_to_look_for = "Index(Integer)"
for x in xrange(tp.NumDataChannels()) :
name = tp.DataChannelName(x)
if name == name_to_look_for:
data_channel_id = x
return data_channel_id
#no channel found
return None
def main() :
global data_channel_id
global count
global Index
#The user might change the data channel,
#so we have to reset the cached channel index
#data_channel_id = None
tp = doc.GetParticleSystem()
channelid = GetUIDChannelID(tp)
Index = tp.GetPData(Particle, channelid)
if Index == None:
tp.SetPData(Particle, channelid, count)
count+=1