Intricacies of 3ds Max Part 1

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:

  1. Rename the object – So you can merge in your object with a new name.
  2. Skip the object – Don’t merge your object in to the scene
  3. 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:

#”(“elephants”,”are”,taking”,”back”,Elephant”,”Tangerines”)

So the ‘logical’ way of sorting this list would result in….

“are”,”back”,”Elephant”,”elephants”,”taking”,”Tagerines”

But alas in 3ds Max it’s

“Elephant”,”Tangeringes”,”are”,”back”,elephants”,”taking”

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)

Will return:

#(“1”,”10”,”11”,”2”)

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)

About davewortley

Somewhere between an artist and a programmer, I like technical things, but being creative. I love problem solving and coming up with elaborate solutions. This blog is where I shall share ideas, tips, tutorials and anything that amuses me.
This entry was posted in 3dsmax, Lessons, MaxScript. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s