Python Field Object and Layer Manual¶
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 ac4d.FieldList
.
Python Field Object can be found in the Create Menu -> Field -> Python Field or in the falloff tab of some objects.
Python Field Layer can be found in the falloff tab of some objects.
Note
A Python Field Object/ Layer should not create/modify objects in the scene.
See also
The important Threading Manual.
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
op (
c4d.modules.mograph.FieldObject
.) – The Python Field Object / Layer.info (
c4d.modules.mograph.FieldInfo
.) – The FieldInfo linked to the current sampling pass.
- 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
op (
c4d.modules.mograph.FieldObject
.) – The Python Field Object / Layer.inputs (
c4d.modules.mograph.FieldInput
.) – The FieldInput linked to the current sampling pass.outputs (
FieldOutput
.) – The FieldOutput to be feded with data, linked to the current sampling pass.info (
FieldInfo
.) – The FieldInfo linked to the current sampling pass.
-
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
op (
c4d.modules.mograph.FieldObject
.) – The Python Field Object / Layer.info (
c4d.modules.mograph.FieldInfo
.) – The FieldInfo linked to the current sampling pass.
- Return type
bool
- Returns
True for success otherwise False will print an error but will not cancel anything.