[Closed] two Qs: Grouping and Version updates
I got two questions. First one is about groups, I know how you can have an array with objects and put them into a new group:
group groupList name:strGroupName.text
However I just can’t seem to figure out how to add and remove from group, using obj and a named group. Any code examples of how to do this?
The other question is about versions. Sometimes when you update your script, you have made changes to it, that makes scenes using the old version, not really work correctly. For example if you move items in rollouts, the parameters doesn’t exist in the same places, so the they turn into default.
What is the best way to make backwards compatible updates, when for some reason, the code change a lot (especially variable names)? Right now I’m playing with an idea of a tool that add an data storage modifier to the objects, that retrieve the data, and then you can update the scripts and recover the data.
For scripted plugins you can provide a mapping of variables for version updates. Might be interesting to check that out.
I’m just about to look into how to make my script backwards compatible (its a modifier and a bunch of stuff has changed). So what do you mean with mapping of variables?
What I need help with is to figure out how to update my modifier to new version, where some of the parameters has changed.
As example:
rollout mainOldRollout rollout:rolloutOld
(
myInt type:#integer animatable:false ui:intMyInt default:1
)
If before update the parameter mInt = 5, after I update the script to the new version and it has changed the name of the rollout, or myInt to myNewInt, the value in it would be 1 instead of 5 because it would use the default (since the ‘new’ parameter didn’t exist before)
Is it possible to retrieve the old parameters and put them into the new ?
Take a look at the maxscript help topic “updating scripted plugins” :
An optional remap: keyword introduced in 3ds Max 7 allows parameter names in the definitions to be changed when updating existing definitions.
The keyword takes as an argument a 2 element array, where each element contains an array of string literal or name values. The size of the 2 arrays must be the same.
Hey, cheers for that. Been looking into it, but have some troubles I hope you might have an answer on.
I managed to change one parameter name to another, however I moved a couple into another rollout, and I think it might be why it doesn’t work. The first line works, the second one doesn’t seem to do anything (Yes, double AA)
remap:#(#("strConvertGroupName"),#("strGroupName"))
remap:#(#("intAmount1D"),#("intAAmount1D"))
strConvertGroupName and strGroupName are both in the same unchanged rollout, but intAmount1D and intAAmount1D are in two different ones. Is there a way to get the values to move over?
Hm are they still in the same parameter block? According to the help you cannot move them across parameter blocks, but I don’t see why assigning a different UI property would make a difference…
Not that it will be much of a solution to your problem, but what I did a few years back when I had a plugin that drastically changed was that I basically made a new plugin and wrote a script that handled the conversion. That gives you full control over the conversion process. It does mean that you will have to keep your old plugin around though, if only hidden.
Cheers. yeah I think I know what you mean, the old parameter kinda looked like this:
parameters mainAmount rollout:rolloutGeneralSettings
(
xAmount type:#integer animatable:false ui:intAAmount1D default:1
)
parameters mainSelection rollout:rolloutSelection
(
----
)
And for one thing I changed mainAmount to mainGeneralSetting to make it more logical and since amount wouldn’t be in that rollout anymore. So it ended up like this:
parameters mainGeneralSettings rollout:rolloutGeneralSettings
(
----
)
parameters mainSelection rollout:rolloutSelection
(
xAmount type:#integer animatable:false ui:intAAmount1D default:1
)
With the variable moved, but also the first parameter group changed name. Was thinking that there must be a way to transfer the data, maybe using if version == 2 do .
I thought that I might do something like this:
parameters mainAmount rollout:rolloutAbout
(
xAmount type:#integer animatable:false default:1
)
parameters mainGeneralSettings rollout:rolloutGeneralSettings
(
----
)
parameters mainAmount rollout:rolloutGeneralSettings
(
xAmount type:#integer animatable:false ui:intAAmount1D default:1
)
parameters mainSelection rollout:rolloutSelection
(
xNewAmount type:#integer animatable:false ui:intAAmount1D default:1
)
And then recover the data with version, but I don’t really like that, since it would mean parameter blocks with no function.
yeah, I thought about something like that as well, but it just doesn’t seem very efficient, and an annoyance for the user. Was just wondering if I could make a solution that made updating just install and it works.
The script I did was for a scripted material, and just automatically updated the deprecated instances of the plugin after a scene load event. The only thing the user noticed of this was the amazing new features :wip:
Okay, I ended up doing an “on update do” and “if version ==” script that would replace the new parameter blocks with the old parameter block values. Seem that it works now.
Cheers for the help.