Python Field Object / Layer

Introduction

It’s possible to create a Python Field Object and a Python Field Layer. The main differences are:

  • A Python Field Object is an object within the scene (this means that it gets a position the user can define).

  • A Python Field Object is independent (this means it can’t retrieves previous fields values from a c4d.FieldList).

  • A Python Field Layer is not an object exposed in the scene, it only exists in a c4d.FieldList, which is, most of the time, owned by an object.

  • A Python Field Layer can retrieves previous c4d.FieldOutput of a c4d.FieldList.

Python Field Object can be found in the Create Menu -> Field -> Python Field or in the falloff tab of some objects.

../../_images/python_field_object.jpg

Python Field Layer can be found in the falloff tab of some objects.

../../_images/python_field_layer.jpg
A Python Field Object is implemented through a FieldData which is not available in Python. Take a look to the C++ doc for more information.
A Python Field Layer is implemented through a FieldLayerData which is not available in Python. Take a look to the C++ doc for more information.
Keep in mind, a Python Field Object or Layer can be executed from different contexts(e.g. A Python Field Object can be used in a Plain Effector with the color mode and in another Plain Effector with only position mode), so please always check for FieldInfo.

Note

A Python Field Object/ Layer should not create/modify objects in the scene.

See also

The important Threading Information.

Methods

InitSampling(op, info)
Override - Optional method, called once before all sampling occurs. Usually used to allocate or create objects.
It can be called multiple time per frame.

Note

If global variables are allocated it’s mandatory to free them in InitSampling() with del(VariableName).

Parameters
Return type

bool

Returns

True for success otherwise False will cancel sampling.

Sample(op, inputs, outputs, info)
Override - called for each FieldOutputBlock. FieldOutput values should be defined in this function.
It can be called multiple time per frame.

Note

In a Python Field Layer only, output variable is already populated with previous values of the c4d.FieldList.

Parameters
FreeSampling(op, info)

Override - called once after all sampling has occurred. Usually used to clean object created in InitSampling(). It can be called multiple time per frame.

Parameters
Return type

bool

Returns

True for success otherwise False will print an error but will not cancel anything.