Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Register
    • Login

    Python Field - Object Data Update

    Cinema 4D SDK
    python r21 windows
    2
    3
    577
    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.
    • C
      cybor09
      last edited by

      Hello,

      I created my first Python Field script, it measure the distance between one camera and each clone, everything works almost fine at this point but I don't know why for some reason, when I move the camera the field doesn't update the data from the camera position.

      I need to disable and re-enable the field to update the camera data, I also tried to add "c4d.EventAdd()" on the script to force the refresh but didn't worked, someone know what I'm missing to get a proper update of the field when I move the camera?

      You will find the demo file below, thanks a lot.

      explorer_2fZHQMkqfj.gif

      c4d camera field.c4d

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hi,

        For "optimisation" the field calculation is not done every time something change in the scene. You can still add a python tag on the field, and check for the dirtiness of the camera. The python tag is executed every time something changes in the scene. It is not the best workaround but it works.

        After creating a User Data that store a link to the camera, the code could look like this.

        def main() -> None:
            if op[c4d.ID_USERDATA,1].IsDirty(c4d.DIRTYFLAGS_ALL):
                op.GetObject().SetDirty(c4d.DIRTYFLAGS_ALL)
        

        You can adjust the flag of your dirty functions using those flags.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • C
          cybor09
          last edited by

          Hello @m_magalhaes ,

          Thanks a lot for the tip, works perfectly as you said 😁

          Cinema_4D_F7fyNZcvZ4.gif

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