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

    Userdata not updating correctly on primitive splines & polygons in 2024..

    Cinema 4D SDK
    2024 python
    2
    4
    750
    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.
    • jochemdkJ
      jochemdk
      last edited by jochemdk

      Hi, I’ve got a simple but strange case in 2024 (while it was working properly before..)

      There’s a simple script to hide userData on a python tag.
      Depending on the on/off state of the switchBoolean, 1 of the other 2 pieces of user data needs to be hidden.
      This works fine on editable splines & polygons, but not on primitive versions - with the exact same tag..

      So, there must be something happening on the primitive splines and polygons, which I don’t understand..
      The pyTags are set to “generators 499”, so that couldn’t be it.

      The issue is that on the primitives, when the switch says ON, the user date shown say OFF and visa versa..
      And only after clicking the “wrong” boolean on the right, the other version will show up. So I need an extra click to get the right result.
      (note: working on Mac right now, haven't tested it yet on PC..)

      strange_UD_update.jpg

      Is there anything new to “updating/redrawing” the UI, or is this something to be fixed in a future update?

      Kind regards, Jochem

      strange_UD_update_01.c4d

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

        Hello @jochemdk,

        thank you for reaching out to us. In short, what you are doing is a violation of the threading restrictions of Cinema 4D. Your main function does not run on the main thread and your changes go therefore unnoticed in a certain sense. Even worse, you could protenially crash Cinema 4D in doing this.

        The solution is to offload your work to message, as this function often runs on the MT ; but you must still check with c4d.threading.GeIsMainThread for not being on the MT. In your case you could use MSG_DESCRIPTION_POSTSETPARAMETER as the message to hook into when you want to react to a changed value in the user data.

        When I was a user myself, I once posted this example, which is a script which populates its own UI once the code is pasted into a Python generator. It hooks into MSG_GETREALCAMERADATA to do that (which is a bit hacky), but other than that, is absolutely the same.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • jochemdkJ
          jochemdk
          last edited by

          Hi Ferdinand, thx for your answer - although I didn't expect this, considering I never ever had any trouble with the script..
          But your point is clear. It means I've got to do some more investigation..

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

            Hey @jochemdk,

            That is the nature of threading restrictions. It is like crossing the street without looking left and right: It works fine until it doesn't 🙂

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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