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

    Python Effector questions

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 426 Views
    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.
    • H Offline
      Helper
      last edited by

      On 23/11/2017 at 07:57, xxxxxxxx wrote:

      Hi,
      I am doing some Python Effector Experiments and would like to ask a few questions:
      This is the simplest code to increment a variable inside the Effeector:

      \> import c4d  
      \> from c4d.modules import mograph as mo  
      \> #Welcome to the world of Python  
      \>  **num = False**  
      \> def main() :  
      \>     global num  
      \>       
      \>     if doc.GetTime() == doc.GetMinTime() :  
      \>         num = 0  
      \>           
      \>     num +=1  
      \>     print (num)  
      \>       
          return True
      

      the num=false, is there so that if I save the scene with the play head is NOT on frame 0, and reload, I don't get an error.
      1. What exactly does num=false mean?
      2. In the context of the Python Effector, what happens to anything outside the main function? When is it evaluated?

      Thanks

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 24/11/2017 at 04:26, xxxxxxxx wrote:

        In "Parameter Control", main is called once for every clone (or even parameter? not entirely sure) and is
        supposed to return a weight for that clone, which will be multiplied by the Python Effector's parameters in
        the "Parameter" tab.

        In "Full Control" mode, main() is called once  to control all clones at once, requiring you to fill in all
        the information for every clone in one go (as the example code shows by using md.GetArray() and
        md.SetArray()).

        1. False is just a boolean value, indicating the absence or invalid nature of something 😉 You can however
        add a number of False and it will act like the integer 0. You can do the same with num=0 (which would
        be more consistent with the rest of your code).

        2. The outside of the main function is executed   only  when the Python generator is associated used by
        a MoGraph object that is not  empty, and only  once  to load the main() function into memory.
        When you change the code and press the "Execute..." button in the editor or close and open the scene
        again, the code will also be loaded once  (with the above conditions still applying).

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 24/11/2017 at 04:31, xxxxxxxx wrote:

          Thanks Niklas.
          Very helpful

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