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

    R19 EventAdd() in tag workaround?

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 563 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 04/10/2017 at 03:17, xxxxxxxx wrote:

      Hey there,

      I hope this question is not too basic..

      I searched the forums, but I cant find a proper workaround for using c4d.EventAdd() in a python tag.
      I already tried DrawViews() as well as sending a dummy CoreMessage.

      This change seems to break a lot of scripts around the internet so it would be nice to have a proper, c4d plugin-developer-confirmed workaround

      Thanks everyone

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

        On 04/10/2017 at 04:09, xxxxxxxx wrote:

        I suggest you to read https://developers.maxon.net/docs/py/2023_2/modules/c4d.threading/index.html?highlight=threading#threading-information.
        SO no is not possible directly to add event inside a python tag.
        Why? Simply because your python code is executed into [TagData.Execute()](https://developers.maxon.net/docs/py/2023_2/modules/c4d.plugins/BaseData/NodeData/TagData/index.html#TagData.Execute) function so it's a threaded function.

        But what you can do is register another plugin. (MessagePlugin) and into your python tag send a message to your message plugin. And this one will run your code into the main thread.
        For more information make sure to read 
        https://developers.maxon.net/forum/topic/9847/13260_christmas-competition-2016--executeinmainthread

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

          On 04/10/2017 at 04:53, xxxxxxxx wrote:

          Oh I had a fear it would be like this.
          Luckily we are running a company internal plugin-suite so it should be easy to add this function.

          Thank you 🙂

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

            On 05/10/2017 at 04:03, xxxxxxxx wrote:

            Hi,

            As pointed out by gr4ph0s EventAdd() must not be called from within the execution pipeline.
            The Python expressions (Python Tag, Generator, Effector and XPresso operator) are executed during such threaded process.
            So it is forbidden to modify the active document and to call drawing functions for instance. See the Forbidden Functions.

            Expressions are executed after an event has been registered. So calling EventAdd() from such process adds again an event and ends up in a continuous update of a scene.

            Since R19, using EventAdd() from within a Python expression does nothing.
            If EventAdd() or any other forbidden function has to be called from an expression then the operations from within its code should be moved to a script/plugin executed in the main thread.

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