View Full Version : Dynamically obtaining custom attribute parameter names in Array

01 January 2009, 11:10 AM
Forgive me, I'm sure this has been answered before but i couldn't find it on the search. I have an attribute that I want to be able to store the parameter settings into an XML file.

say i have an attribute like so -

Attributes Test
parameters main(
value1 #type:float
value2 #type:string
value3 #type:boolean

This all works fine but at the moment in the saveXML routine I am manually defining a local array of parameters , one for the name, one for the value. -

ie - "parametersarray = #("Value1", value1, "value2", value2, "value3", value3)

which i then save out to XML in my loop.

I have seen Custattibutes.GetPblockDefs <def>

which allows me to to say

theatt = custattributes.getdef (custattributes.get $.modifiers 1)
pblockdefarr = Custattributes.GetPblockDefs theatt
parametername1 = pblockdefarr[1][5][1] as string

is this the correct way of doing this to retrieve the parameters names and values? in this case the parameters are fixed in number and type but thought it would be a helpful thing to know, and with code, I've always thought if it looks ugly, it probably is. ;)

01 January 2009, 12:24 PM
typos aside ( one shouldn't author scripts in a forum ;) ), yep - that's the way. You're not storing the parameter type with your xml?

Edit: I thought this question looked familiar - darn the weekends :)

01 January 2009, 12:41 PM
ta rich- yes, I was typing from memory so being monday morning I'm surprised it was just that! :D

01 January 2009, 12:44 PM
Edit: I thought this question looked familiar - darn the weekends :)

that was the fella! be damned my goldfish brain!

CGTalk Moderation
01 January 2009, 12:44 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.