Notifications
Clear all

[Closed] Dynamically obtaining custom attribute parameter names in Array

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.

3 Replies

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

ta rich- yes, I was typing from memory so being monday morning I’m surprised it was just that!

that was the fella! be damned my goldfish brain!