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

    Tag update while a python script is running

    Scheduled Pinned Locked Moved PYTHON Development
    8 Posts 0 Posters 1.5k 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 16/04/2018 at 23:28, xxxxxxxx wrote:

      Hello.

      This is my problem:
      I have an object ("cone") with an Ttargetexpression.
      I transform the target object ("ziel") via a python script in a "for" loop (e.g. 10 steps)

      ziel[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Z] = float(i)*100

      After each step i trasform a group including the "cone" and the "ziel" object to a new object ("c4d.CallCommand(12233, 12233)").

      After running the script i got 10 new groups with 2 objects each. the "ziel" object has changed its position in each step) but the "cone" has not rotated.

      I think it has to do with priority of the "Ttargetexpression" Tag. But i don't know how to handle the problem.

      It would be great if someone could help me.

      Best regards

      Heiner

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

        On 17/04/2018 at 05:19, xxxxxxxx wrote:

        Hi Heiner,

        welcome to the Plugin Café forums 🙂

        The problem is, scripts (and all CommandData plugins actually) run in the main thread (and thus block the main thread). So Cinema 4D is doing nothing else but executing your script. Or in other words, the scene does not get evaluated during your for-loop.
        The solution is to trigger the evaluation of the scene by calling ExecutePasses() in your for-loop.

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

          On 17/04/2018 at 05:29, xxxxxxxx wrote:

          Thank you very much for your reply and the nice welcome.
          Unfortunatly it does not yet work 😞

          This is my code:

          -----------------------------------
          import c4d
          from c4d import gui
          import time

          #Welcome to the world of Python

          def main() :
           
            objekt_ziel = doc.SearchObject('ziel')
            objekt_wuerfel = doc.SearchObject('wuerfel')

          hauptobjekt = doc.SearchObject('ICL_python')
            hauptobjekt.SetBit(c4d.BIT_ACTIVE)

          for i in xrange(-10, 10) :

          objekt_ziel[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X] = 0
                objekt_ziel[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Y] = 500
                objekt_ziel[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Z] = float(i)*100

          doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_INTERNALRENDERER)
                
                hauptobjekt.SetName("ICL_animation_" + str(i) )
                c4d.CallCommand(12233, 12233) # Akt. Zustand in Objekt wandeln

          hauptobjekt.SetName("ICL_python")

          if __name__=='__main__':
            main()

          -------------------------

          Can you please help me?

          Thanks

          💡

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

            On 17/04/2018 at 05:41, xxxxxxxx wrote:

            Hello Heiner,

            can you please tell me in what way it does not work?
            I tried your script here with the following object hierarchy:
            ICL_python
              |- wuerfel
              |- ziel

            And as a result of your script I get 20 Null objects "ICL_animation_N" with "wuerfel" as a child, each pointing into a different direction.

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

              On 17/04/2018 at 06:33, xxxxxxxx wrote:

              The scene looks like this:

              ICL_python
                |- ziel
                |- kegel

              The "kegel" object has an "Ausrichten"-Tag (sorry. I do not know the english name of that tag) with "ziel" as its target.

              The result is 20 Null object with each one translated "ziel" and one not rotated "kegel".
              So i think the "Ausrichten"-Tag does not work within my script.

              Thanks for the help.

              Heiner

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

                On 17/04/2018 at 06:42, xxxxxxxx wrote:

                But your script searches for "wuerfel"...

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

                  On 17/04/2018 at 06:43, xxxxxxxx wrote:

                  Sorry. it was an old version of the script.
                  Please forget this line.

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

                    On 18/04/2018 at 10:03, xxxxxxxx wrote:

                    Now, I'm confused about which line to forget.

                    I still think, here the script works as expected. See here the result of your script:

                    ![]([URL-REMOVED]


                    [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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