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

    Listening for Selection Events

    Cinema 4D SDK
    python
    3
    5
    592
    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.
    • ?
      A Former User
      last edited by

      Hello,
      I am making a Command plugin and would like to listen to C4D's selection events to find the new active objects. Is this possible? I have seen examples of plugins that listen to C4D events, but they are MessageData plugins. I don't see an object selection event in GeDialog:CoreMessage.

      The events I am seeing from CoreMessage on selection are c4d.EVMSG_CHANGE and c4d.EVMSG_DOCUMENTRECALCULATED, but these are happening with every mouse click.

      May I please ask how would this be done?

      Thank you!

      1 Reply Last reply Reply Quote 0
      • M
        mp5gosu
        last edited by

        In case of an object selection change, you can simply call GetActiveObjects() in every EVMSG_CHANGE call.

        Or, read in selection bits for all objects.

        ? 1 Reply Last reply Reply Quote 0
        • ?
          A Former User @mp5gosu
          last edited by A Former User

          @mp5gosu That worked, thank you very much! Would one way be faster than the other?

          1 Reply Last reply Reply Quote 0
          • M
            mp5gosu
            last edited by

            Since it is python, I'm not entirely sure. But I'd say getting the bits is faster, since no allocation is made (like a list in GetActiveObjects()).
            But this can probably answer the SDK team.

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

              hello,

              To retrieve the active object you have to iteration trough the hierarchy. (even GetActiveObject)
              In Python, GetActiveObjects is calling a c++ function so with lots of object it will be faster than iterating the hierarchy with python functions.
              We don't know what the limit is. To mesure that you have to make a bunch of tests with different scenarios and get the mean.

              Cheers,
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

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