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
    • Register
    • Register
    • Login

    detect the selection of an object

    Cinema 4D SDK
    python
    4
    13
    2.7k
    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.
    • M
      mp5gosu
      last edited by

      That's a PickSession Candidate, right?

      1 Reply Last reply Reply Quote 0
      • Passion3DP
        Passion3D
        last edited by

        PickSession?

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

          A PickSession() lets you retrieve objects. The transfer tool uses something similar.
          Although, it may not be possible to directly click in the object tree with a tool enabled (and there are no tools in C4D that I know of), but you could add a link to your tool that allows you to pick an object that should be considered for placing.
          Take a look at the transfer tool - maybe that's what you're looking for.

          1 Reply Last reply Reply Quote 0
          • Passion3DP
            Passion3D
            last edited by Passion3D

            It's from R19 only. It will remove OnFloor compatibility from R13 to R18 😞

            M 1 Reply Last reply Reply Quote 0
            • C4DSC
              C4DS
              last edited by

              I have been in need of something similar as well. And if I remember correctly it has been discussed a few years ago.
              Reason is that a ToolData or DescriptionToolData might need to initialize some stuff depending the currently active object. When the user selects a different object in the ObjectManager, the ToolData might need to reinitialize some stuff.

              The solution proposed in the past was to use a MessageData and listen to EVMSG_CHANGE to check if a different object has been selected using the object's "unique" id and then trigger the ToolData by sending a SpecialEvent ... or something.

              It is quite a complex implementation that seems to work, but probably is very error prone.
              I wish we would have had some kind of message telling the active object selection was changed (from inside the ToolData), not via-via. And definitely not using such a hacky and complex solution.
              It has been a while, but I seem to remember that the whole use of the object's unique id was rather flawed as the id didn't exactly seem to be that unique after all.

              Anyway, I am still hoping for a nice solution to detect when user changes the current active object. But it seems to not be possible after all.

              1 Reply Last reply Reply Quote 2
              • M
                mp5gosu @Passion3D
                last edited by

                @passion3d said in detect the selection of an object:

                It's from R19 only. It will remove OnFloor compatibility from R13 to R18 😞

                If I'm not mistaken, in prior versions it must have been ViewportSelect.PickObject().

                C4DS approach sounds a bit more elegant, yet hacky and thus probably error-prone. I'd go for the more robust solution. Even if that means a lack in comfort.

                1 Reply Last reply Reply Quote 0
                • Passion3DP
                  Passion3D
                  last edited by

                  ViewportSelect.PickObject(), this is what I use to select an object in the 3D View.

                  What I'm trying to do seems complex and unreliable.
                  I'll try to find another solution.
                  As I said, when the scene is complex, it is difficult to reach a particular object, especially if it is small.

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

                    Then, why don't you simply add a LinkListGui or a Link field? I had a similar plugin written, which allows me to build a list for snapping candidates. That works pretty well.

                    1 Reply Last reply Reply Quote 1
                    • C4DSC
                      C4DS
                      last edited by

                      @Passion3D
                      As this topic seems to be "solved" could the solution be provided, or discussed. It might be helpful to others. And I am definitely interested to hearing a solution in more details.

                      1 Reply Last reply Reply Quote 0
                      • Passion3DP
                        Passion3D
                        last edited by

                        @C4DS
                        Although a solution has not been given (as I wish to do), explanations have been provided. I have therefore considered it resolved.
                        For IRL reasons, I could not do so. I will be able to get back to it, and if I find THE solution, I will post it 😉

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