How to save nested arrays variables with the scene?
Hi,
I wrote a script for handling multiple scene setups for rendering by storing multiple properties and their associated "objects" in variables that I store in a rollout of a custom attribute. It saves with the scene and it works pretty well as long as I don't close the Max session.
If I close and reopen Max I think what happens is that the rollout gets opened and so reset its local variables. Damn...
I don't want to use params because that means I have to split somehow every properties by type and I was avoiding that thanks to the fact that arrays can contain any type of data.
Basically I was storing in one array the array of property names first and property values second like that
objProps = #()
for obj in Objects do
(
names = #()
values = #()
for i in getPropNames obj do
(
append names i
append values (getproperty obj i)
)
append objProps #(obj, names, values)
)
(sorry I don't know how to add TABulations)
is there any way???
Comments
Thanks! I know about these
Thanks!
I know about these renderPass scripts and they are great but a lot too generic and complex to use for my staff...
I am trying to do something quickly customisable for each project, thats why I am looking for doing my own functions to store values and controllers...
I am actually close to success, i did a function to turn the classOf a property value into a type:#name of parameters... I wonder why it doesn't exist natively... like a typeOf()
I am again bumping into a wall with that last issue, if a value is undefined, that means has not been set by the user it is impossible to know the type...
for example I usually have nothing in #adv_irradmap_saveFileName so if I getProperty of that it outputs undefined but if I try to setProperty to undefined I get an error.
I would like to set to something empty, like ""for this property but I can't test if it is a string without trying every type of value...
I can do a specific workaround for Vray and for now but I would like to make it more generic to be able to tweak future version of this pass manager and keep it as simple as I can on the user side...
Any clue on how to guess the type of an undefined value in a defined param ?
`
hey, just sent you an email, but quickly you are on very good track.
write/read your parameters
Write the initial settings for a given control to a file and when you open the rollout read these settings (setINIsettings..., getINIsettings) or use custom attributes as miauu suggested.
.
Use Node User-Defined Properties and Methods, or Use Custom Attributes.
To add tabulations put the code between "
" "code here" "
"without the quotes.
Tools and Scripts for Autodesk 3dsMax
I probably don't understand
I probably don't understand properly but my understanding of user props is that it is limited to string.
I am currently finding a work around with strings in a custom attribute as parameters since it seems to be the only way to have it saved with the scene and not reset with new max session. I am r ally looking forward to understanding better but such short answer is hard for me who has no coding background and is struggling with the lingo of the help files.
`
You can use Custom Attributes as Miauu suggested.
But to store mixed array as u want is not that easy.
Start form example:
http://forums.cgsociety.org/archive/index.php?t-369543.html
What you need to do is create Dummy, put it on some safe layer zzz_Scene_Paramiters and hide. (just named it as you want to)
than run this:
than you can access it by:
more info:
http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=fil...
Hope it helps,
Best,
Pixamoon
that is what I am trying to
that is what I am trying to do right now but it is a hell of complexity... always bumping into walls of special case...
for example storing/restoring VRay setting with array is as simple as:
Vrender = renderers.current
propNames = #()
propValues = #()
--Get Vray Properties
for i in getPropNames Vrender do
(
val = getProperty Vrender i
if val != undefined then
(
append propNames i
append propValues val
)
)
--Set Vray properties
for i = 1 to propNames.count do
(
setProperty Vrender propNames[i] propValues[i]
)
I am about to give up setting CA since converting string is limited to certain classes only. Converting some superclass like "filter" doesn't even seem to be possible
I am not yet giving up but...
How do you insert maxscipt
How do you insert maxscipt code in your post?
`
Hi,
to post script here do that:
<_code_>
...
...
<_/code_>
just without underscore _ in <_code_> and <_/code_>
`
to save render setting in scene, take a look on:
http://www.scriptspot.com/3ds-max/scripts/l-pass-manager
or
http://www.scriptspot.com/3ds-max/scripts/prism
or one more thing...
converting string back to different type of variables: (boolean, color, Point2, Point3... etc) you can use just:
a = execute ("color 10 10 10")
or even to Array with different types inside:
arr = execute ("#(12, true, [10,10,10], color 10 10 10)")
this way u can even store it as string in dummy with Node User-Defined Properties
One thing you can't story this way is node or arrays of nodes
(include / exclude)
for that you can store node handles (obj.handle) or store them in #nodeTab array