Half of what I know isn’t just how to solve a problem, but why that problem exists and when we are just using work-arounds to get around problems. Here are a few examples which may seem illogical at first, but are important to understand.
Object Names are not unique…
Objects in 3dsmax don’t need to have unique names, this can make certain things a bit complicated, like if using the getNodeByName() function, it will only return one occurrence of the object, and I’ve noticed that the one it picks can be different in local and slave mode. There is an extra parameter for getnodebyname “thisName” all:True which will give an array of all the objects with this name.
When you are merging objects in to the scene, either by script using mergeMaxFile or using the dialog when you have duplicate object names you have to choose what you do….. Either:
- Rename the object – So you can merge in your object with a new name.
- Skip the object – Don’t merge your object in to the scene
- Merge the Object – Merge the object in without changing any names creating a conflicting name.
So if 3dsmax doesn’t work on object name basis to identify objects how does it actually work? Well it’s what’s called the handleID of the object. You can see any handleID of any object by querying it’s handle property. It’s not something exposed to the UI, and it doesn’t persist with the object when it’s merged in to another scene. You can’t have two objects with the same handle so when merging a file in, all the handles of the merged objects will be += the number of objects in the scene before merging.
Sorting names alphabetically doesn’t quite do what you expect
The sort() function allows you to sort a list of strings into alphabetical order.. Great says the artist, I know all about sorting alphabetically, I learned that at primary school. Wrong. In the computer world, objects are sorted slightly differently.
Suppose I gave you this list:
So the ‘logical’ way of sorting this list would result in….
But alas in 3ds Max it’s
This is because it’s sorting based on something like byte size order where ‘E’ is before ‘a’. You may have seen this in the scene explorer in max already. And unfortunately/fortunately the sort function returns the same result.
Other intricacies of sorting to be aware of are with differently formatted string numbers.
myAR = #(“2”,”1”,”10”,”11”)
myAR = sort(myAR)
So to avoid this you will need to pass these items to an Integer array and then sort that and then put the values back to strings.
(for n in (sort(for o in myAR collect o as integer)) collect n as string)