[Closed] face selection change callback
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!
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
)
)