TP_MasterSystem

The master system is the main TP engine class. There can only be one master system per document. You can get it with BaseDocument.GetParticleSystem().

Definition

class c4d.modules.thinkingparticles.TP_MasterSystem

Inheritance

Members

TP_MasterSystem.AllocParticle()

Allocates a particle.

Return type:int
Returns:The particle ID of the allocated particle, or NOTOK if the allocation failed.
TP_MasterSystem.AllocParticles(num)

Allocates num particles and stores their particles IDs.

Note

The count of allocated particles might be unequal to num due to the limit in the settings Max Particles. Change it to increase the count of allocatable particles.

../../../../_images/maxparticles.png
Parameters:num (int) – The number of particles to allocate.
Return type:List[int]
Returns:The list with the allocated particle IDs.
TP_MasterSystem.FreeParticle(pid)

Allocates num particles and stores their particles IDs.

Note

Normally this should not be used. Instead you should use SetLife() with a negative time, so that the particle in question dies immediately.

Parameters:pid (int) – Particle ID of the particle to free. Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
TP_MasterSystem.FreeAllParticles()

Frees all particles.

Note

Normally this should not be used. Instead you should use SetLife() with a negative time, so that the particle in question dies immediately.

TP_MasterSystem.AllocParticleGroup()

Allocates a new particle group. Must be freed with FreeParticleGroup(), or inserted into the list with SetPGroupHierarchy().

Return type:c4d.modules.thinkingparticles.TP_PGroup
Returns:The new particle group.
TP_MasterSystem.FreeParticleGroup(group)

Frees a particle group, removing it from the list.

Parameters:group (c4d.modules.thinkingparticles.TP_PGroup) – The group to free.
TP_MasterSystem.SetPGroupHierarchy(parent, group, mode)

Performs a hierarchy action on a particle group.

Parameters:
  • parent (c4d.modules.thinkingparticles.TP_PGroup) – Parent parameter.
  • group (c4d.modules.thinkingparticles.TP_PGroup) – Group to act on.
  • mode (int) –

    Action:

    TP_INSERT_NONE Not used.
    TP_INSERT_UNDERFIRST Insert group as first child of parent.
    TP_INSERT_UNDERLAST Insert group as last child of parent.
    TP_INSERT_BEFORE Insert group before parent.
    TP_INSERT_AFTER Insert group after parent.
TP_MasterSystem.GetRootGroup()

Returns the root group.

../../../../_images/rootgroup.png
Return type:c4d.modules.thinkingparticles.TP_PGroup
Returns:The root group.
TP_MasterSystem.GetParticleGroups(ingroup, mode, subgroups=True)

Returns the particle groups in ingroup, specified by mode.

Parameters:
  • ingroup (c4d.modules.thinkingparticles.TP_PGroup) – In-group parameter.
  • mode (int) –

    Mode:

    TP_GETPGROUP_ALL All groups.
    TP_GETPGROUP_WITHPARTICLES Groups with particles.
    TP_GETPGROUP_SELECTED Selected groups.
  • subgroups (bool) – If this is True sub groups are included.
Return type:

list of TP_PGroup

Returns:

The root group.

TP_MasterSystem.GetGroupParticleCount(ingroup, subgroups=True)

Calculates the number of particles in the ingroup group.

Parameters:
Return type:

int

Returns:

The number of particles.

TP_MasterSystem.GetVirtualObjects(ingroup, inRender=True, subgroups=True, hh=None)

Creates the virtual object hierarchy for a particle group, i.e. an object group containing all particles. Used by the ParticleGeometry object.

Parameters:
  • ingroup (c4d.modules.thinkingparticles.TP_PGroup) – In-group parameter.
  • inRender (bool) – True if this is for rendering, otherwise the objects are built for the editor view.
  • subgroups (bool) – If this is True sub groups are included.
  • hh (HierarchyHelp - Not implemented) –
    A hierarchy helper for the operation.
    Usually passed through from a calling function, for example from ObjectData.GetVirtualObjects() or a Python generator main().
Return type:

c4d.BaseObject

Returns:

Virtual object or None if there was an error.

TP_MasterSystem.GetGroupInfo(group)

Retrieves the group information for a group.

Parameters:group (c4d.modules.thinkingparticles.TP_PGroup) – Group to get the information for.
Return type:c4d.BaseContainer
Returns:The group information for the group.
TP_MasterSystem.GetGroupFromInfo(info)

Retrieves a group from the information in info.

Parameters:info (c4d.BaseContainer) – The information to search for.
Return type:c4d.modules.thinkingparticles.TP_PGroup
Returns:The retrieved group or None if no group matched.
TP_MasterSystem.UpdateGroup(group, timeDelta)

New in version R16.050.

Updates a group at a given time difference since the last update. Use a default timeDelta of 0 to update at the current time.

Parameters:
Return type:

bool

Returns:

True if the update was done successfully, otherwise False.

TP_MasterSystem.NumParticles()

Retrieves the number of allocated particles. All particles IDs are less than this value.

Return type:int
Returns:Number of particles.
TP_MasterSystem.Alive(pid)

Retrieves the alive bit of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:bool
Returns:True if the particle is alive, otherwise False.
TP_MasterSystem.IsBorn(pid)

Retrieves the is-born bit of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:bool
Returns:True if the particle was just born, otherwise False.
TP_MasterSystem.IsDie(pid)

Retrieves the is-die bit of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:bool
Returns:True if the particle just died, otherwise False.
TP_MasterSystem.EntersGroup(pid)

Retrieves the enters-group bit of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:bool
Returns:True if the particle just entered a group, otherwise False.
TP_MasterSystem.Group(pid)

Retrieves the group of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:bool
Returns:The group that the particle currently is in, otherwise None.
TP_MasterSystem.Position(pid)

Retrieves the position of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.Vector
Returns:Particle position.
TP_MasterSystem.Velocity(pid)

Retrieves the velocity of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.Vector
Returns:Particle velocity.
TP_MasterSystem.Mass(pid)

Retrieves the mass of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:float
Returns:Particle mass.
TP_MasterSystem.Spin(pid)

Retrieves the spin of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:float
Returns:Particle spin.
TP_MasterSystem.Size(pid)

Retrieves the size of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:float
Returns:Particle size.
TP_MasterSystem.Scale(pid)

Retrieves the scale of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.Vector
Returns:Particle scale.
TP_MasterSystem.Age(pid)

Retrieves the age of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.BaseTime
Returns:Particle age.
TP_MasterSystem.Life(pid)

Retrieves the lifetime of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.BaseTime
Returns:Particle lifetime.
TP_MasterSystem.Alignment(pid)

Retrieves the alignment matrix of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.Matrix
Returns:Particle alignment matrix.
TP_MasterSystem.Randomseed(pid)

Retrieves the random seed of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.Matrix
Returns:Particle random seed.
TP_MasterSystem.Transform(pid)

Retrieves the transformation matrix of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.Matrix
Returns:Particle transformation matrix.
TP_MasterSystem.Flags(pid)

Retrieves the transformation matrix of a particle.

Note

These are private. Use the functions like Alive() instead.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.Matrix
Returns:Particle flags.
TP_MasterSystem.DTFactor(pid)

Retrieves the delta time factor of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:float
Returns:Particle flags.
TP_MasterSystem.Color(pid)

New in version R16.038.

Retrieves the color of a particle.

Parameters:pid (int) – Particle ID.
Raises:IndexError – If pid is out of range : 0<=pid<NumParticles().
Return type:c4d.Vector
Returns:Particle color.
TP_MasterSystem.SetPosition(pid, p)

Retrieves the delta time factor of a particle.

Parameters:
  • pid (int) – Particle ID.
  • p (c4d.Vector) – New particle position.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetVelocity(pid, p)

Sets the velocity for a particle.

Parameters:
  • pid (int) – Particle ID.
  • p (c4d.Vector) – New particle velocity.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetMass(pid, mass)

Sets the mass for a particle.

Parameters:
  • pid (int) – Particle ID.
  • mass (float) – New particle velocity.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetSpin(pid, axis, speed)

Sets the spin for a particle.

Parameters:
  • pid (int) – Particle ID.
  • axis (c4d.Vector) – Rotation axis.
  • speed (float) – Rotation speed
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetAge(pid, age)

Sets the age for a particle.

Parameters:
  • pid (int) – Particle ID.
  • age (c4d.BaseTime) – New particle age.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetLife(pid, life)

Sets the age for a particle.

Parameters:
  • pid (int) – Particle ID.
  • life (c4d.BaseTime) – New particle lifetime.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetGroup(pid, group)

Inserts a particle into another group.

Parameters:
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetSize(pid, size)

Sets the size for a particle.

Parameters:
  • pid (int) – Particle ID.
  • size (float) – New particle size.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetScale(pid, scale)

Sets the size for a particle.

Parameters:
  • pid (int) – Particle ID.
  • scale (c4d.Vector) – New particle scale.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetAlignment(pid, align)

Sets the alignment matrix for a particle.

Parameters:
  • pid (int) – Particle ID.
  • align (c4d.Matrix) – New particle alignment matrix.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetRandomseed(pid, seed)

Sets the alignment matrix for a particle.

Parameters:
  • pid (int) – Particle ID.
  • seed (int) – New particle random seed.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetCollision(pid, collision)

Sets the collision handling information for a particle.

Parameters:
  • pid (int) – Particle ID.
  • collision (int) – Collision ID. This is GetOperatorID() for the node responsible for the collision handling.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetDTFactor(pid, dt)

Sets the delta time factor for a particle.

Parameters:
  • pid (int) – Particle ID.
  • dt (float) – New particle delta time factor.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetColor(pid, color)

New in version R16.038.

Sets the color for a particle.

Parameters:
  • pid (int) – Particle ID.
  • color (c4d.Vector) – New particle color.
Raises:

IndexError – If pid is out of range : 0<=pid<NumParticles().

TP_MasterSystem.SetPData(pid, chan, value)

Sets the data channel value for a particle:

pid = 1
chan = 0
ms.SetPData(pid, chan, "Hello World!")
Parameters:
Raises:
Return type:

bool

Returns:

True on success, otherwise False.

TP_MasterSystem.GetPData(pid, chan)

Sets the data channel value for a particle:

pid = 1
chan = 0
value = ms.GetPData(pid, chan, "Hello World!")
Parameters:
  • pid (int) – Particle ID.
  • chan (int) – Channel index.
Raises:
Return type:

Any

Returns:

Depends on the type of the channel.

TP_MasterSystem.AddDataChannel(type, str)

Adds a new data channel.

Parameters:
  • type (int) – Channel data type.
  • str (str) – Channel
Return type:

bool

Returns:

True if successful, otherwise False.

TP_MasterSystem.RemoveDataChannel(chan)

Removes a data channel.

Parameters:chan (int) – Channel index.
Raises:IndexError – If chan is out of range : 0<=chan<NumDataChannels().
Return type:bool
Returns:True if successful, otherwise False.
TP_MasterSystem.NumDataChannels()

Retrieves the data channel count.

Return type:int
Returns:Number of data.
TP_MasterSystem.DataChannelType(chan)

Retrieves the data type of a data channel.

Parameters:chan (int) – Channel index.
Raises:IndexError – If chan is out of range : 0<=chan<NumDataChannels().
Return type:int
Returns:Data type of channel chan.
TP_MasterSystem.DataChannelName(chan)

Retrieves the name of a data channel.

Parameters:chan (int) – Channel index.
Raises:IndexError – If chan is out of range : 0<=chan<NumDataChannels().
Return type:str
Returns:Number of data.
TP_MasterSystem.DataChannelUniqueID(chan)

Retrieves a unique ID for a data channel that’s independent of its index.

Parameters:chan (int) – Channel index.
Raises:IndexError – If chan is out of range : 0<=chan<NumDataChannels().
Return type:int
Returns:Unique ID of channel chan.
TP_MasterSystem.DataChannelID(unique_id)

Retrieves the index of a data channel from its unique ID.

Parameters:unique_id (int) – Channel ID.
Return type:int
Returns:Data channel index.
TP_MasterSystem.GetOperatorID(op)

Retrieves an ID for op

Parameters:op (c4d.modules.graphview.GvNode) – A node.
Return type:int
Returns:ID for op.
TP_MasterSystem.GetDirty()

A dirty counter for the master system. This can be used to see if anything has changed. Use SetDirty() to increment the counter.

Return type:long
Returns:Dirty counter. Is incremented when something changes in the system.
TP_MasterSystem.SetDirty()

Increments the dirty counter, i.e. tells anyone using GetDirty() that something has changed.

Note

This has to be used whenever an operator affects particle shapes, like the ObjectShape operator does.