[Closed] Max Plugin Variable Transfer
I wrote a little plugin that’s based on a line with a few additional parameters. It’s working well, but there’s one tweak I would like to make to speed up the workflow. If I make a line, and I set it to render in viewport as a rectangle and a set the size of that rectangle, those settings will carry over if I start a new line. I have several parameters on my plugin that are defined as variables with a default amount. Whenever I make a new line with my plugin, my varaibles return to their default value instead of whatever I had them set to last time I used the plugin. Is there a way so if I change a variable while running the plugin, the next time I run the plugin that variable will stay to what I set it? I don’t need it to do it should the file close or anything, just to work more or less the way the standard primitives do.
the safest you can do is to put last ‘created parameters’ in an INI file.
if you want to do it just for current session of max you can store last specified ‘created parameters’ in local scope of your plugin. and use them in case if one of them was not specified
there is another (built-in) way to do it … it’s to use type:#class definition on a parameter block
see the help >> Scripted Plug-in Clauses
here is an example:
plugin simpleObject OneClickBox
name:"OneClickBox"
classID:#(0x02feb67, 0x444444)
category:"Examples with denisT"
(
parameters main type:#class rollout:params
(
size type:#worldUnits default:1 ui:ui_size
)
rollout params "Params"
(
spinner ui_size "Size: " type:#float range:[0,FLT_MAX,1] fieldwidth:56 align:#right offset:[4,0]
)
on buildMesh do
(
mesh_obj = createInstance Box width:size length:size height:size
setmesh mesh mesh_obj.mesh
)
tool create numPoints:1
(
on mousePoint click do case click of
(
1:
(
nodeTM.translation = gridPoint
#stop
)
)
)
)
but there is a bug in this method… when you evaluate the code of this plugin next time the system will give you error message like:
– Error occurred in anonymous codeblock; filename: …
** system exception **
so the bugging is not friendly. as a solution – debug your plugin well without type:#class and add it to the definition later