PDA

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


LoneRobot
01-19-2009, 10: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. ;)

ZeBoxx2
01-19-2009, 11:24 AM
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 :)
http://forums.cgsociety.org/showthread.php?t=718538

LoneRobot
01-19-2009, 11:41 AM
ta rich- yes, I was typing from memory so being monday morning I'm surprised it was just that! :D

LoneRobot
01-19-2009, 11:44 AM
Edit: I thought this question looked familiar - darn the weekends :)
http://forums.cgsociety.org/showthread.php?t=718538

that was the fella! be damned my goldfish brain!

CGTalk Moderation
01-19-2009, 11:44 AM
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.