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

    Randomize objects in object manager?

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 422 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 06/02/2013 at 02:14, xxxxxxxx wrote:

      Hi all,

      Is there a way to make a script that randomizes the order of objects under a null in the object manager?

      Grtz,
      Hans Willem

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

        On 06/02/2013 at 03:14, xxxxxxxx wrote:

        Easy:

        import random
          
        def main() :
            objs = op.GetChildren()
            [x.Remove() for x in objs]
            random.shuffle(objs)
            [x.InsertUnder(op) for x in objs]
          
        main()
        

        Note: no undos

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

          On 06/02/2013 at 03:26, xxxxxxxx wrote:

          Wow! Thanks!

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

            On 06/02/2013 at 14:11, xxxxxxxx wrote:

            Forgot to add c4d.EventAdd() as the last line of the main() function. This will update the Cinema
            4D interface so you can see the change immediately.

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