[Closed] Maxscript: Change name of a newly created dummy
Hi.
Maxscript issue.
I have an UI interface with a checkbutton. When that checkbutton is on (true), newly created Dummies should change name.
I’m pretty lost right now, and would like to kindly ask for help.
The code from this thread suggests something that looks pretty simple, but it returns “Type error: Call needs function or class, got undefined”.
http://forums.cgsociety.org/archive/index.php?t-928026.html
Any ideas appreciated. Thank you!
It would be better to see your code. But I’m almost certain that you just failed to provide correct reference for the callback function
try (destroydialog X ) catch ()
rollout X "" (
checkbox cb "checkbox"
fn renameNewDummy = (
local addedNode = callbacks.notificationparam()
if isKindOf addedNode Dummy and cb.checked do addedNode.name = uniqueName "RenamedDummy"
)
on X open do (
callbacks.removeScripts id:#dummyRenamer
callbacks.addScript #sceneNodeAdded "[b]::x.renameNewDummy()[/b]" id:#dummyRenamer
)
on X close do (
callbacks.removeScripts id:#dummyRenamer
)
)
createDialog X
Ah thanks! What if I have two or more types of dummies within the same rollout whose name change is triggered by each of the checkbuttons?
I can paste some code tomorrow
try (destroydialog X ) catch ()
rollout X "" (
checkbutton cb "superDummy"
checkbutton cb2 "extraDummy"
checkbutton cb3 "megaDummy"
local checkbuttons = #( cb, cb2, cb3 )
fn toggle ctrl state = (
checkbuttons.checked = false
ctrl.checked = state
)
fn renameNewDummy = (
local addedNode = callbacks.notificationparam()
if isKindOf addedNode Dummy do (
case of (
(cb.checked == true): addedNode.name = uniqueName cb.text
(cb2.checked == true): addedNode.name = uniqueName cb2.text
(cb3.checked == true): addedNode.name = uniqueName cb3.text
default:()
)
)
)
on X open do (
callbacks.removeScripts id:#dummyRenamer
callbacks.addScript #sceneNodeAdded "::x.renameNewDummy()" id:#dummyRenamer
)
on X close do (
callbacks.removeScripts id:#dummyRenamer
)
on cb changed state do toggle cb state
on cb2 changed state do toggle cb2 state
on cb3 changed state do toggle cb3 state
)
createDialog X
it would be better to use nodeeventcallback instead of general callback event. because function for node event can be local, but general event function is always global.