I found this thread, that does just what I want, but for some reason, I cannot delete/remove the When callback, so it keeps running when I don’t want it to.
It is possible using a WHEN construct instead of the general callback scripts. The callback will be executed each time the monitored objects are selected or deselected, but also catches changes in the sub-object selections, so it should work for you. Of course, you can keep track of what was previously there or what SO mode you are in and only act when the user really selected/deselected vertices, faces or edges.
Assuming you are going to use it in PolySpeed where you already know which objects you want to monitor, it would be very easy to implement:
when select $ changes id:#Bobo obj do (print (getfaceSelection obj))
Note that $ can stand for one or more selected objects, and the when construct will monitor them all. So you could also say when select selection changes… or when select #($Box01,$Box02) changes… or when select mySelectionArray changes … (where mySelectionArray is a collection of nodes).
‘select’ means you want to be notified when the objects or their subobject get selected/deselected.
the ID lets you easily delete specific callbacks
‘obj’ is an argument that is passed to the expression after DO and will contain the actual object that has changed. In the case above, I am asking for the face selection of the one object that has changed. You could do something like
… do if subObjectLevel > 3 then print (getfaceSelection obj)
to only access the face selection when in face mode and so on…
Hope this helps,
Here is what I’m doing, but it doesn’t want to work.
when select selection changes id:#objPlacer do ( placeObjects() )
Then to remove the callback I am trying
Any ideas? Thanks!