PDA

View Full Version : Custom Attribute local variables: getter, no setter?


shea241
12-22-2010, 05:33 PM
Say I have a custom attribute defined this way:
TestCA = attributes "Test" AttribID:#(0x68319294, 0x12da900a)
(
local testVariable = "Good Day Sir";
)

When I apply it to an object, I can get the value of testVariable on the object (it is auto-promoted to the base object), but MaxScript tells me 'testVariable' does not exist when I try to set it. However, setting it on the custom attribute itself works fine (object.Test.testVariable).

Additionally, I can write my own setter function on the custom attribute and set the local that way.

Three theories:
1) This is a bug, and the setter should also be auto-promoted to the base object
2) This is a bug, and custom attribute locals should not be being auto-promoted at all
2) This isn't a bug, and custom attribute locals are promoted in a read-only way for protection (I can't imagine why, though)

I also don't recall running into this issue in previous versions of Max (specifically 9.0), but I can confirm this happens in 2009 and 2010.

Anybody have some insight into the problem?

Here's a script displaying the issue in full:
TestCA = attributes "Test" AttribID:#(0x68319294, 0x12da900a)
(
local testVariable = "Good Day Sir";

function SetTestVariable value =
(
testVariable = value;
)
)

(
prettyCone = Cone();
CustAttributes.Add prettyCone TestCA;

-- getting the local works fine
testVariableValue = prettyCone.testVariable;
format "prettyCone.testVariable is '%'\n" testVariableValue;

-- setting it this way works fine too
prettyCone.SetTestVariable "Very well ...";

-- and so will setting it this way
prettyCone.Test.testVariable = "Very well ...";

-- but setting it this way will *not*
prettyCone.testVariable = "Very well ...";
)

CGTalk Moderation
12-22-2010, 05:33 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.