wrong results when rendering using fields within a python effector
-
Hello, I've got a problem using the Clone object with a Python Effector that uses a field. I hope this is the right subforum for this kind of problem.
The Python-Code:
md = mo.GeGetMoData(op) fall = md.GetFalloffs() print("fall "+str(fall))
In the Editor it returns a number like it should, but when I render it always returns 0.0. I've attached the C4D File including a screenshot. I'm using the latest C4D Version 2024.3.2
-
Hi thanks for reporting it, this will be fixed in an upcoming release (not necessary the next one).
As a workaround you can sample the field yourself like so:
import c4d from c4d.modules import mograph as mo #import redshift def CustomGetFalloffsForFields(): md = mo.GeGetMoData(op) mdcount = md.GetCount() # Prepare FieldOutput flags = c4d.FIELDSAMPLE_FLAG_VALUE outputs = c4d.modules.mograph.FieldOutput() outputs.Resize(mdcount, flags) # Prepare FieldInputs values mdmat = md.GetArray(c4d.MODATA_MATRIX) positions = [matrix.off for matrix in mdmat] normals = [matrix.v3 for matrix in mdmat] uvws = md.GetArray(c4d.MODATA_UVW) callerMG = gen.GetMg() if gen and gen.IsInstanceOf(c4d.Obase) else Matrix() inputs = c4d.modules.mograph.FieldInput(positions, len(positions), callerMG) # Prepare FieldInfo values callerStack = c4d.modules.mograph.FieldCallerStack() callerStack.Add(gen) infos = c4d.modules.mograph.FieldInfo() infos._flags = flags infos._callerThread = c4d.threading.GeGetCurrentThread() infos._doc = gen.GetDocument() infos._callerStack = callerStack infos._inputData = inputs # Sample the field op[c4d.FIELDS].SampleList(infos, inputs, outputs) return outputs._value def main(): md = mo.GeGetMoData(op) if md is None: return False cnt = md.GetCount() fall = CustomGetFalloffsForFields() print("fall "+str(fall)) for i in range(0, cnt): if fall[i] > 0: print("################## YES!!! IVE FOUND A PRODUCT!!!") return True return True
Cheers,
Maxime. -
-
Hi Adam, thanks for the update and the workaround!