Passing var value from rollout to macro script
Hi!
I'm having a problem with a script I wrote. My main script is a macro script which I have assigned to a keyboard shorcut. The other script is a simple rollout with a pickbutton which stores an object in a global variable.
My macroscript should be able to read this global variable, but it only happens if I open a macro editor and evaluate an entire script (instead just using a shortcut). Otherwise it will just keep reporting undefined.
Once the macroscript is evaluated in script editor, I can use the pickbutton in the rollout to change the picked object and macroscript will respond correctly when activated by a keyboard shortcut.
Why does it work only if evaluated once an object is picked? Is there a way around it?
Many thanks in advance for any help or suggestions!
>>>>>>EDIT<<<<<<
Finally found a solution that made my script "usable"! I've added:
fileIn "DropDown.ms"
at the beginning of the UI part, so a macro script gets automatically run every time a UI is started.
Comments
Post the code.
Post the code.
Tools and Scripts for Autodesk 3dsMax
I've stripped the code to
I've stripped the code to essential parts. I have the UI part in startup and macro binded to a keyboard shortcut. If I open the scene, select one object using UI and then call macro function, it will report dropDownTerrain as undefined. But if I run macro script first (using MAXScript/Run Script...) and then invoke it with a shortcut, it will work (in case presented, it will give no warning at all)
macro:
UI:
if ((dropDownUI != undefined)
Tools and Scripts for Autodesk 3dsMax
Thanks, but it didn't work.
Thanks, but it didn't work. In fact, I've put that there in an attempt to solve the problem.
Would it be possible to run macro script from the UI part?
What the macro do? Check only
What the macro do? Check only if the terrain is undefined?
You can have only one script - with the UI. With the Pick object button you get the terrain object, and with another button you will execute the code that is in the macro, but you will not have a separate macro. Doing this you will have only local variables.
Tools and Scripts for Autodesk 3dsMax
Macro takes a current
Macro takes a current selection of objects and aligns them on a surface selected by UI. I really wanted a macro script that could be activated by a keyboard shortcut instead of having a button to click. If nothing else works, i'll have to fall back to that option.
Thanks again for the effort! :)
Try this. No need to press
Try this. No need to press another button - pick the node and the code from the macro will be executed.
Tools and Scripts for Autodesk 3dsMax
Yeah, I understand what you
Yeah, I understand what you mean... I'll try that, thanks!
And this is from maxscript
And this is from maxscript help file. :) Almost what you want without UI.
Tools and Scripts for Autodesk 3dsMax
Heh, I remember now reading
Heh, I remember now reading this code. I wonder what on isEnabled ... on Execute does. I understand its an event of sorts, but what happens if selection count returns false? And what causes those vents to occur?
I'll have to look into this. :D