Notifications
Clear all
[Closed] macroscript… isVisible not working
Oct 27, 2010 8:15 pm
ok so i keep having this problem with macroscripts in quad menu…
so here’s one macroscript…
macroScript MePoly
category:"RappaTools"
buttonText:"MePoly"
--tooltip:"Convert selection to Editable Poly."
(
on isVisible do (try( Return (RappaTools.open and RappaTools.poly.enabled) )Catch(false))
on isEnabled do (try( Return (RappaTools.open and RappaTools.poly.enabled) )Catch(false))
on execute do RappaTools.poly.pressed()
)
when i open 3ds max ( vs 2011 32/64 | vs 9 ) the quad menu does not update if i open rappatools… if i run the macroscript again it works perfectly…
tried many many ways but still can’t make it work right… how can i make it work right !?
2 Replies
Oct 27, 2010 8:15 pm
Scope of variables :o)
If the RappaTools variable is declared as global AFTER the MacroScript is evaluated, the MacroScript will have created a local variable with that name already and won’t see the real one.
As usual, there are two possible solutions:
- Declare RappaTools as global in the beginning of the MacroScript.
- Use double-colon :: in front of RappaTools calls to force global scope.
In other words, either do this:
macroScript MePoly category:"RappaTools" buttonText:"MePoly"
(
global RappaTools
on isVisible return RappaTools.open and RappaTools.poly.enabled
on isEnabled return RappaTools.open and RappaTools.poly.enabled
on execute do RappaTools.poly.pressed()
)
or this
macroScript MePoly category:"RappaTools" buttonText:"MePoly"
(
on isVisible return ::RappaTools.open and ::RappaTools.poly.enabled
on isEnabled return ::RappaTools.open and ::RappaTools.poly.enabled
on execute do ::RappaTools.poly.pressed()
)