detect the selection of an object



  • Hi all
    In a tooldata, is it possible to detect when the user selects an object in the tree structure?



  • Hi,

    no, that's not possible. Can you give us a use-case, where this is needed for in a ToolData? Maybe we can come up with something else.

    Cheers,
    Andreas



  • Hi Andreas
    It's an improvement I want to make to OnFloor.
    Currently, the tool is activated and then click on each object in the 3D view to place it on the ground.
    In the case of a complex scene, it can be difficult to find an object in the 3D view. So I would like to include the possibility of clicking on the object in the scene tree structure.



  • That's a PickSession Candidate, right?



  • PickSession?



  • 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.



  • It's from R19 only. It will remove OnFloor compatibility from R13 to R18 :(



  • 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.



  • @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.



  • 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.



  • 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.


Log in to reply