[Closed] custom attributes and scene states
Hi!
I need to save some additional info to camera object and did it by adding user properties with setUserProp command. It was all ok until I discovered that user properties are saving with scene states. For example, if I have two scene state and set some property to 1 in first scene state, then change scene state to second and set property to 2, switching scene state back to the first sets user property back to 1. That was the problem that ruined script’s behavior, so I decided to switch to custom attributes.
I did some tests with custom attributes, assigned some CA to box object, created scene states, switched them, changed values, switched back and everything was ok – with box object scene state doesn’t affect custom attributes!
But that’s not true for the camera object! Camera’s custom attributes are saving with scene states. How could it be possible?
Now I really don’t know what to do. The only visible way for me to store info that is not affected by scene states is saving CA to rootnode. But that requires extra effort to link camera objects and rootnode’s CAs.
I have two questions
- Is there a way to avoid saving maxobject’s custom attributes with scene states?
- Is there effective method to link CAs attached to rootnode and objects in scene?
Any help will be much appreciated.
Here’s simple test code:
to set attribute:
temp_attrdef = attributes "temp_attribute"
(
parameters presetParam
(
test_preset type:#integer
)
)
custAttributes.add $ temp_attrdef
to get attribute and to set the property:
temp1 = custAttributes.get $ 1
print (temp1.test_preset)
No one uses CA attached to the objects? Is there a way to avoid storing CA data to scene state?
Thank you in advance!
I can definitely see some unwanted stuff happening when switching a scene state and a CA on the baseObject. But I have a hard time reproducing it exactly, just one time I switched states and the CA was gone. After reapplying it sticked with whatever I did on the scenestates.
Have you tried a attribute holder modifier with a CA on it?
-Johan
Thank you Johan, I was using invisible CA-s, attached by the maxscript, and completely forgot about ca holder. Did some tests and found strange results. Although the behavior that was the cause of my confusion looks more logic now.
CA holder attributes attached to the camera or light object works as expected with scene states – values are saving in scene states as all other values.
CA holder attributes attached to the box object are not affected by the scene states – values are saving to the file but they’re not changing when I switch the scene state. They simple retain last entered value.