ZBrushCentral

Q: VarLoad from file , array mis match

Hi

I am saving variables to a file that is of a certain size. Then I am loading it in for use in a later session with zbrush. I have updated the variable size which no causes issues when loading the old files saved out, due to mis match in array size. Is there a way for zbrush to test the array and returning value’s rarther then giving me a error.

For example:

//Export file with size of 45
[VarDef, transforms(45),0]
[IButton,“Export”,
[VarSet, camPath, [FileNameAsk, “ZVR(.zvr)|.zvr”, “File name”, “Title name”]]

[Note, [StrMerge,[FileNameExtract, camPath, 2]," file exported"],,.7] [VarSave,transforms, camPath]

,.5]

//Import file but with array changed
[VarDef, transforms(90),0]
[IButton, Import,
[VarSet, camPath, [FileNameAsk, “ZVR(.zvr)|.zvr”, , “Title name”]]
[Note, [StrMerge,[FileNameExtract, camPath, 2]," file imported"],.7]

[VarLoad,transforms,camPath] // error array mismatch
]

The miss match makes sense but just can’t figure a way out to catch the error in a true/false way so the script doesn’t exit but just checks.

Thanks

If you set VarLoad to verify only then it will return 0 if there’s a mismatch. So long as you have a limited number of possibilities you can load the file into the correct variable:

[If,[VarLoad,transforms,camPath,1] == 45,
//OK
[VarLoad,transforms,camPath]
,//else
[VarLoad,transformsB,camPath]
]

Note that I’ve used transformsB as the second variable name. You declare your transforms variable twice which is not a good idea and will lead to problems.

Incidentally, if you are saving out transforms you might find it better to use a memory block and MTransformGet and MTransformSet. You can save the memory block to file and then create a new memory block from the file as needed. A simple check of the block size will tell you how many values you have. There’s also a size limit with TransformGet/Set that is avoided.

Hi Marcus

I should of tried that was a pretty simple solution! The reason for my variable changing was just in example to simulate what has happened. I made a plugin with 5 camera’s but now updated it with 10 camera’s so the variable doesn’t change in the plugin as much in versions.

I realized that mem blocks was the better option after I already made the plugin and info was saved out so don’t think I would be able to use it in this project but definitely something to keep in mind.

Thanks once again!