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
    • Login

    Make Python Generator update on User Data change

    Cinema 4D SDK
    2024 2025 python
    2
    3
    612
    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.
    • K
      karpique
      last edited by karpique

      Hi, I have a Python Generator that uses fields with SampleListSimple() function. It should change the position of generated geometry based on provided field sample values. Fields are connected to Pyhton Generator with User Data -> Field List. It works good, I can tweak field values and Pyhon Generator updates accordingly, but if I try to turn off / turn on / add / remove field from field list, Generator is not updated accordingly to that event (however if I turn off field itself, not in user data but in objects tree, generator updates well).

      So far I managed to get that event:

      def message(id, data):
          if(id==c4d.MSG_DESCRIPTION_POSTSETPARAMETER):
              flId = eval(str(data['descid']))[1][0]
              if flId == 1:
                  myFieldList = op[c4d.ID_USERDATA, 1] #trying update global FieldList value, no sucess
      

      I've tried to push "force update" button on this event, but got error that says button execution should be only from main thread. So the question -- how to properly refresh Python Generator when parameters of fields in FieldList User Data (such as turn on/off, name, blending, opacity) are changed?

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @karpique
        last edited by

        Hello @karpique,

        Thank you for reaching out to us. Please follow our support procedures in future regarding providing a question that is for repeatable, we otherwise might refuse support.

        Your problem is likely tied to cache optimization being enabled, this has been discussed before here for example. To not write essays due to the unbound nature of your question, I answer in the video below.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • K
          karpique
          last edited by

          Thansk so much for the video, that was a deep dive! For my issue, I resolved it like this:

          def message(id, data):
              if(id==c4d.MSG_DESCRIPTION_POSTSETPARAMETER):
                  userDataID = eval(str(data['descid']))[1][0]
                  if userDataID in [2, 4, 5]:
                      c4d.CallButton(op, c4d.OPYTHON_MAKEDIRTY)
          

          so, if any user data touched (including fieldlist), the generator updates itself.

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