[Closed] Update values on selection
Im trying to have a script update everytime a new object is selected.
My script works out the area of the selected object, but id like it to report the area of any object when the user selects a new object.
At the moment they have to hit an update button to refresh the area.
Is there anyway to do this dynamically?
ie something like:
on selection changed thestate do
(
)
Thanks
Hi,
Try using a callback:
when select selection[1] changes id:#selX64 do print “Selection Changed”
Don’t forget to remove it when you no longer need it:
deleteAllChangeHandlers id:#selX64
Light
A WHEN construct is not a good idea, because it MONITORS specific objects.
You should use a general callback
callbacks.removeScripts id:#MySelectionCallback
callbacks.addScript #SelectionSetChanged "print \"Selection Changed!\"" id:#MySelectionCallback
instead.
The first line makes sure there are no older callbacks with that ID, the second registers the callback which is executed any time your scene selection changes, (both select or deselect).
To disable it, call the first line alone again…