[Closed] max2009 to max2012 scripts
Ive created/edited a lot of scripts last and this year. They worked somewhat in max2009 but unfortunately yesterday we upgraded to max2012 and a LOT of scripts stopped working
Especially grouping related scripts. So my question is in order to fix it where should I start looking, where can i find what has changed in the scripting language from 2009 to 2012?
For example one of the first scripts:
(
fn RecurseGroupMember =
(
for i in objects do (if (i != undefined and isGroupmember i == true) do unGroup (GetNodeByname(i.parent.name) ))
Group objects
for i in $group01 do (
$group01.pos = [0,0,i.pivot.z]
for i in objects do (if (i != undefined and isGroupmember i == true) do unGroup (GetNodeByname(i.parent.name) ))
clearSelection()
)
)
RecurseGroupMember()
)
This script adds all the objects into 1 group and centers it.
error I get is [no “map” function for undefined.]
Ive noticed a lot of my scripts don’t work because of the naming of objects. in 2012 all primitive objects are named with 3 decimals 001, 002, 003 etc and in max2009 it was only 2. I know I have already asked in the other forum but if anyone here knows how to change it default to 2 decimals, would be appreciated.
Thanks
The maxscript documentation contains a number of pages “What’s new in maxscript in 3dsmax x”.
Instead of relying on the new group’s name, which is a bit of a gamble regardless of your 3dsmax version, you could use:
local newGroup = group objects
Following the “What’s New in 3ds Max 2011”, you can find in the topic “Interface: maxOps” the property:
<integer>maxOps.nameSuffixLength
Controls the number of digits appended as suffix to the name of newly created scene nodes, layers etc.
NOTES:
The default value was changed from 2 to 3 and is now controlled by the “NameSuffixLength” key in the [Preferences] category of the 3dsmax.ini file.
This is to ensure better sorting of up to 999 objects using the MAXScript sort() method. If you intend to work with more than 1000 objects, you can increase the maxOps.nameSuffixLength value to 4 or more to ensure enough leading zeros.
In addition, note that newly created nodes will receive a number one higher than the highest number in the scene without filling gaps. For example. if you create objects Box001, Box002 and Box003 and delete Box002, the next automatically named object will have the name Box004 and not Box002.
Really, is that the reason? :shrug:
That seems like very backward reasoning to me. If the expected behavior of Maxscript’s sort() is that it should do a nice logical sort, then the implementation of sort should be changed, not the way objects are numbered, surely…
thanks pjansen will check into that and the group script. Always had problems with groups, and ungrouping somehow so I might be back if i get stuck again.
Bobo, Splendid. Couldnt find it in any of the 3dsmax.ini files so I just added it manually
[Preferences]
maxOps.nameSuffixLength = 2
And it worked. Thanks alot, helped me fix a lot of my scripts
Try downloading the latest 2012 hotfix. I had the same issue where old scripts stopped working. One issue I had was 2012’s inability to but an attribute holder on a point helper which is a known issue and stopped my scripts running. HotFix fixed this…worth a try
Thanks DDufy, already installed service pack 2, but Bobo’s trick about the objects number was the biggest problem, 90% of my scripts worked on that. Now glad to finally have everything running smooth again
It was related to a scripted AddModifier section I had in a script. Max kept saying it couldn’t recognise AddModifier for some reason? After I ran the hotfix it worked a charm
you have to fix your code… not the name suffix length. the using of pathnames in code is not a good practice.
(all my codes since max 5 work without any problem in max 2013. some of them look naive now, but they are still working)