View Full Version : face selection change callback

12 December 2008, 02:32 PM
Hey everybody!

I'm working on a script that offers a smoothing-group-like UI for material IDs. As in: loads of small button, one per ID.

For this I need a a function that highlights the buttons according to the material IDs of the selected faces.
Do you know a good callback/change handler that can do this?
I tried 'when geometry changes', but it doesn't get called on selection change.

Thanks and merry christmas!

12 December 2008, 03:17 PM
You can either use the "when select" changeHandler, or use the Node Event System (3ds Max 2009) which has a subObjectSelectionChanged callback function parameter.

Note that the "when select" changeHandler also triggers on standard node selection/deselection, so it's up to you to filter those out and only worry about subObject-level selection changes.

Edit: example for meshes

myObj = $
oldFaceSelectionCount = ((myObj.selectedFaces as bitArray) as array).count
deleteAllChangeHandlers id:#test
when select myObj changes id:#test do (
newFaceSelection = myObj.selectedFaces as bitArray
newFaceSelectionCount = (newFaceSelection as array).count
if (newFaceSelectionCount != oldFaceSelectionCount) then (
oldFaceSelectionCount = newFaceSelectionCount
matIDs = #()
for i in newFaceSelection do (
appendIfUnique matIDs (getFaceMatID myObj i)
print matIDs #nomap

01 January 2009, 05:27 PM
Works like a charm.

CGTalk Moderation
01 January 2009, 05:27 PM
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.