Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    wrong results when rendering using fields within a python effector

    Bugs
    python 2024 windows
    2
    3
    902
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      TSD
      last edited by

      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

      Python-Effector-problem_0001.c4d Anmerkung 2024-03-27 201820.png

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        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.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • M m_adam moved this topic from Cinema 4D SDK on
        • T
          TSD
          last edited by

          Hi Adam, thanks for the update and the workaround! 👍

          1 Reply Last reply Reply Quote 0
          • First post
            Last post