Welcome to the world of mystery.

Thinking Particles in c4d using python

Hey everyone!
I've been in the dungeon working on learning all the new python goodies. Now with r13 the entire mograph module is at your disposal, so there's that, but I wanted to take a step back and write about how to create some more basic stuff in python. Up until now, the only method by which to create thinking particles was through xpresso or the matrix object. Well, now the python generator can be added to your arsenal. Let's go through the basic process by which we can create some particles!

1) create a python object.(duh)

2) first, we need to retrieve the document that are particles are going to exist in. There are a couple ways to accomplish this in python c4d.
- you can import the documents module("from c4d import documents") and use
- or you can get the document from the python object ("op.GetDocument()")

3) once the document has been retrieved, the Thinking Particle Master System(TPMS) can be retrieved from the document using the "GetParticleSystem()" command on your document.

4) once we have the TPMS we can do anything we want. Refer to the sdk for commands, but basically, we can create particle("TPMS.AllocParticle()"), remove particles ("TPMS.SetLife(particleID, -1)"), set velocities("TPMS.SetVelocity(pid, c4d.Vector())"), etc.

An example of some code is below:

import c4d

def Main():
Doc = op.GetDocument()
TPMS = Doc.GetParticleSystem()
NumParticles = 20
for i in xrange(NumParticles):
id = TPMS.AllocParticle()# this also returns the #particle ID
TPMS.SetLife(id, doc.GetMaxTime()) # set life to the doc length
TPMS.SetPosition(id, c4d.Vector(0, id*100, 0)

Hope that helps get u started. More to come!