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

    Python "undo" changes the original selection order

    Bugs
    python
    3
    6
    1.5k
    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.
    • R
      reubenlara
      last edited by Manuel

      Hello! My script relies on selection order and works fine. however, when I undo and run the script again immediately, the selection order is changed (somewhat reversed), and it toggles the reversal consistently. Why is it doing this? And is there a way to make sure the selection order stays constant when re-invoking the script?

      You can see a clearer explanation of my problem:
      in this brief screen recording

      import c4d
      from c4d import gui
      
      def main():
      
      
          doc.StartUndo()
      
          selected = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
      
          #print order of object names to console
          print ("start:")
          names = []
          for obj in selected:
              names.append(obj.GetName())
          print (names)
      
          #distribute objects
          for idx, ob in enumerate(selected):
              doc.AddUndo(c4d.UNDOTYPE_CHANGE, ob)
              print (ob.GetName())
      
              ob[c4d.ID_BASEOBJECT_GLOBAL_POSITION,c4d.VECTOR_X] = 0
              ob[c4d.ID_BASEOBJECT_GLOBAL_POSITION,c4d.VECTOR_Y] = 0
              ob[c4d.ID_BASEOBJECT_GLOBAL_POSITION,c4d.VECTOR_Z] = 0 + (idx * 1000)
      
      
          c4d.EventAdd()
          doc.EndUndo()
      
      if __name__=='__main__':
          main()
          c4d.EventAdd()
      
      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        I've open a bug report for this.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        R 1 Reply Last reply Reply Quote 1
        • R
          reubenlara @Manuel
          last edited by

          @m_magalhaes Excellent thank you! Will you post the results here? Or is there a another link I should follow?

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

            hi,

            well, first it needs to be fixed, then release on a cinema4D's update (hotfix, service pack, release)

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            R 1 Reply Last reply Reply Quote 0
            • R
              reubenlara @Manuel
              last edited by

              @m_magalhaes ah ok thanks for the clarification. So, at this point, you can confirm that this is a bug and not a mistake in implementation on my part?

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

                yes exact, it's a bug not an error from your implementation.

                MAXON SDK Specialist

                MAXON Registered Developer

                1 Reply Last reply Reply Quote 0
                • maxonM maxon moved this topic from Cinema 4D SDK on
                • First post
                  Last post