Sub-Object Selection Changed Callback



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[1] changes id:#objPlacer do

Then to remove the callback I am trying

callbacks.removeScripts id:#objPlacer

Any ideas? Thanks!


The reason the callback isn’t being removed is becase it is a change handler. To remove the change handler use this code:

deleteAllChangeHandlers id:#objPlacer

Edit (some more info):

Also, you’ve forgotten to add your object reference to the change handler:

when select selection[1] changes id:#test obj do
	print obj

Also, it may be a better idea to use nodeEventCallback instead:

global nodeVertsChange

function exampleFn s e = (for a in e do print (getAnimByHandle a))

nodeVertsChange = nodeEventCallback subobjectSelectionChanged:exampleFn

To remove callback:

nodeVertsChange = undefined
gc light:true


MXS: Pick a Vertex (Similar to Pickobject)

Nice! Thanks alot! Seems to work just fine :smiley:


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.