So I’m trying to make a tool which collects all the modifiers in the scene, adds them into an array as a string. That array is used for a listbox to show the modifiers as the items.
Now I wanna make it so that I can just select the modifier from the listbox and then turn them on and off. But I am unable to figure out how I’d even get the right modifier based on what I’m selecting in the listbox since the items in the listbox are strings and now the actual modifiers.
Here is what I’ve got up until now…
clearListener()
try(destroyDialog modifierR)catch()
rollout modifierR "ModifierTest"(
group "Select Modifier"(
listbox modifierListLb "" width:150 across:2
button mdRefreshBt "🗘" offset:[36,0]
)
group "Manage"(
button onModifierBt "Modifier On" width:(modifierR.width/2-14) across: 2 offset:[5,0]
button offModifierBt "Modifier Off" width:(modifierR.width/2-14) offset:[10,0]
)
fn getPolyMods modClass =(
PolyMods=#()
for obj in selection do(
for md in obj.modifiers do(
if classOf md==modClass then(
append PolyMods md
)
)
)
PolyMods
)
fn getTheList =(
theList=#()
theList
)
fn getObjModList =(
objModList=#()
objModList
)
on modifierListLb selected nameIndex do (
print modifierListLb.items[nameIndex]
-- select (getNodeByName (modifierListLb.items[nameIndex]))
-- print selection
)
on modifierR open do(
theList = getTheList()
objModList = getObjModList()
for obj in selection do(
for m in obj.modifiers do(
appendIfUnique theList ((classof m) as String)
appendIfUnique objModList m
)
)
modifierListLB.items=theList
)
on mdRefreshBt pressed do(
theList=getTheList()
objModList = getObjModList()
for obj in selection do(
for m in obj.modifiers do(
appendIfunique theList ((classof m) as String)
appendIfUnique objModList m
)
)
modifierListLB.items=theList
print theList
)
on setMditerationsBt pressed do(
-- print mdIterationsSp.value
Polymods = getPolyMods TurboSmooth
-- print PolyMods
for i = 1 to Polymods.count do(
Polymods[i].iterations = mdIterationsSp.value
-- print Polymods[i].iterations
)
)
on onModifierBt pressed do(
theList = getTheList()
objModList = getObjModList()
for i = 1 to objModList.count do(
if classOf objModList[i] == (modifierListLB.items[nameIndex]) then(
print (modifierListLB.items[nameIndex])
objModList[i].enabled = true
)
)
)
on offModifierBt pressed do(
PolyMods=getPolyMods TurboSmooth
for i = 1 to PolyMods.count do(
PolyMods[i].enabled = false
)
)
)
CreateDialog modifierR width:200