Notifications
Clear all

[Closed] 3ds Max 2016 and custom attributes

Hello guys (and girls, who knows…),

Since Max 2016, as soon you select an object, it will get automatically a Mental Ray custom attribute (mental_ray__Displacement_Custom_Attributes).
Until there, nothing too bad.

But, when excuting this:

local ca_test = attributes "CA_TEST" (parameters lightmappedObject(helloWorld type:#boolean animatable:false default:true))

local b = box()
custAttributes.add b ca_test baseobject:false
print (b.custattributes) --#CustAttribs(CA_TEST:CA_TEST)
select b
print (b.custattributes) --#CustAttribs(CA_TEST:CA_TEST, mental_ray__Displacement_Custom_Attributes:mental ray: Displacement Custom Attributes)
print (custattributes.getDefs b baseobject:false) -- #(<AttributeDef:CA_TEST>)

The custattributes array is not matching the custattributes defs array.
The Mental Ray attribute def is not in the custattributes defs array of my object.
Both array indices are not consistent anymore.

It bothers me a lot because my script have to know the index of a given attribute.
I thought I would workaround this by artificially adding 1 to the result if the object is selected but it doesn’t work. The MR attribute stays on the object even when you deselect the object.

I have found nothing on the internet about this. Am I the only one to get this weird behavior?
Have you a nice workaround for this, by any chance?

Thanks for advance,

4 Replies

I’m sorry to bring this topic back on the top of the stack but I have several tools using custom attributes which are impacted by this strange new behavior.

In order to come back on the issue, I originally thought that this attribute was added for their new “fancy” selection outline feature but turning it off doesn’t change anything.

I can’t find a way to remove it.
You can replace it in the Def Array, but as soon as you select the object it is there again.

However, custattributes.get() seems to work correctly with the indexes.

Also, if you don’t use MR, you can set:

mental_ray_Preferences.mrExtensionsActive = false

It will prevent the CustAttrib to be added to the object.

You are right. custAttributes struct methods (add, delete, get, …) works without taking the Mental Ray attribute into account.
Thanks for the workaround !

The only thing that you can’t do anymore is to set a CA directly in the custattributes array:

node1.custattributes[x] = node2.custattributes[y]

because you don’t know where the extra MR attribute is inserted.
In this case, you have to delete the CA from the node the re-add it.

But thank you anyway! It saved my day! I wouldn’t have thought that the virtual CA array differs from the custattributes struct results.

Don’t hesitate if you have a better workaround/explanation :).
I hope it will help somebody else because there is still nothing about that on the web, as far as I sought.

Furthermore, I believe it is a major retro-compatibilty issue for any script working with attributes using the CA virtual array, as I did until there.
My guess would be that many older scripts will crash in 3dsmax 2016. Maybe nobody switched to 2016, though…

Best Max Ever, guys !!!..