Set an object name that doesn't match the filename?

Adam Murray's icon

In the SDK examples, the times~ object uses this line of code:

class_setname("*~","times~"); // because the filename on disk is different from the object name in Max

However, this seems obsolete under the new API. I can comment it out and the behavior doesn't change.

I wanted to accomplish something similar in an object I was working on, and thought I could use class_alias(), but this causes compile to fail during the linking stage, which seemed odd.

I also tried changing the first param to class_new() to be the name I want but that seems to be ignored.

In the new API, is the only way to use a name that doesn't match the project/filename to append to the max-objectmappings.txt or audio-objectmappings.txt file (or perhaps add an additional custom mappings file)? Or am I missing something?

Peter Castine's icon

Since about Max 4.3 (or so) the xxx-objectmappings.txt file is the official way to go. You will want to put your definitions into something like adam-his-object-mappings-list-or-whatever-you-want-to-name-the-file.txt. The name doesn't matter as long as the file has a .txt suffix and is in the init folder and isn't a file name that Max might clobber on the next update.

However, offhand I'm not sure why class_setname() & Co. aren't working for you.

Adam Murray's icon

Peter Castine wrote on Wed, 15 April 2009 05:03Since about Max 4.3 (or so) the xxx-objectmappings.txt file is the official way to go. You will want to put your definitions into something like adam-his-object-mappings-list-or-whatever-you-want-to-name-the-file.txt. The name doesn't matter as long as the file has a .txt suffix and is in the init folder and isn't a file name that Max might clobber on the next update.

Thanks for the info.