PDA

View Full Version : Is there a way to...


Polimeno
02-09-2010, 07:17 PM
Change the custom attribute variable name on-the-fly using another 'free variable' ?

test 1:

test_CA = "CTRL_Rigging"
ca = attributes test_CA
(
local CA = "Testing_CA_Variables_Name"
)
custAttributes.add ($.baseObject) ca


--returns
--"CTRL_Rigging"
--<AttributeDef:test_CA>
--true

test 2:

test_CA = "CTRL_Rigging"
ca = attributes (execute(test_CA))
(
local CA = "Testing_CA_Variables_Name"
)
custAttributes.add ($.baseObject) ca


-- returns
-- Error occurred in anonymous codeblock; position: 134; line: 5
-- Syntax error: at (, expected name
-- In line: ca = attributes (e

test 3:

test_CA = #("CTRL_Rigging")
ca = attributes test_CA[1]
(
local CA = "Testing_CA_Variables_Name"
)
custAttributes.add ($.baseObject) ca


-- returns
-- Error occurred in anonymous codeblock; position: 144; line: 5
-- Syntax error: at [, expected (
-- In line: ca = attributes test_CA[1


thanks in advance

PEN
02-10-2010, 12:08 PM
I think that you are going to have to build the entire ca def with a string and execute it.

Polimeno
02-10-2010, 01:57 PM
I think that you are going to have to build the entire ca def with a string and execute it.

thatīs it Paul, it works !


str = "
ca = attributes #
(
local CA = 1.0
)
custAttributes.add (@.baseObject) ca

"
s2 = "#"
s3 = "CTRL_Rigging"
str_1 = substituteString str s2 s3

s2 = "@"
s3 = ( "$" + (selection[1].name) )
str_2 = substituteString str_1 s2 s3

execute str_2

-- returns
true

thanks.

CGTalk Moderation
02-10-2010, 01:57 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.