Notifications
Clear all

[Closed] How to query scripted custom attribute array

Anyone know how to query scripted custom attribute array?

Basically, I have a scripted custom attribute something like this,


textKeyDataCA = attributes textKeyData
(
parameters main rollout: params
(
[indent] textkey_name type:#string ui:textkey_list default:””
textkey_id type:#integer ui:textkey_inform default:1
)
rollout params “Text Key List”
(
GroupBox textkey_gp “Text Key Information” pos:[10,162] width:136 height:56
label textkey_inform ” Text Key ID: ” pos:[18,180] width:125 height:13

                 listBox [b]textkey_list[/b] "Text Key:" [b]items[/b]:#("fire","summon","spell") pos:[10,5]
                on textkey_list selected i do
         (

[indent] textkey_name = textkey_list.items[i]
textkey_id = i
textkey_inform.text = “Text Key ID: ” + “[ ” + (textkey_id as string) + ” ]”
)
[/indent] )
[/indent] )
custAttributes.add $ textKeyDataCA #unique


I can only do $.textKeyData.textkey_name to get current selected textkey in the list,but I can not figure out how to query textkey_list to get the array of textkey_list.items.

And, I tried custAttributes.getDefs, but only got #textkey_list, not textkey_list.items.

Any ideas,appreciate!

5 Replies

rollouts and their UI elements aren’t really part of the custom attribute data – just of the definition; the UI is entirely for display and user interaction purposes only, as is volatile. I.e. if you were to add a new item to that listbox, that item will be lost the moment your UI closes as it doesn’t get stored in any actual custom attribute data.

So to answer your question of how one might get the UI bits… the short answer is that you can’t. The slightly longer answer is that you can use something like…

(custAttributes.getDef $.textKeyData).source

…and parse the source code manually. However, that will only get you the UI values as defined in the source, not as they may have been altered since then.

What you’d really want to do, however, is add a #stringTab & tabSizeVariable:true parameter to hold the list of items in the listbox. The listbox itself should be reading from this stringTab (an array, put simply), and the listBox interaction for adding/removing items should interact with that stringTab. You already have a parameter to identify the currently selected item as a string – more common would be an integer (which can then be used to read the actual value out of the stringTab), but strings work

if you’re not storing values like richard said you could still use the rollout to get the array –

$.params.textkey_list.items
$.params.textkey_list.items[1]
$.params.textkey_list.items[2]
$.params.textkey_list.items[3]

Thanks a lot.

Is it possible to create an array custom attribute? something like this,

 parameters main rollout: params
 (        textkey_name type:#string ui:textkey_list default:""     
     textkey_id type:#integer ui:textkey_inform default:1[indent][b]textkey_list_array[/b] type[b]:#array[/b] ui:textkey_list default:#()   [/indent])

Seems like the type of custom attributes are limited to #string,#Float and #integer,etc, but no #array type.

Anyway,will try #stringTab you suggested. Thanks.

yes there is a ‘tab’ version of all of these types that will store an array which pertains to the declared type –

Scripted Plug-in Clauses[left]#floatTab
[/left]
[left]#intTab
[/left]
[left]#indexTab
[/left]
[left]#colorTab
[/left]
[left]#rgbTab
[/left]
[left]#frgbaTab
[/left]
[left]#point3Tab
[/left]
[left]#point4Tab
[/left]
[left]#boolTab
[/left]
[left]#angleTab
[/left]
[left]#percentTab
[/left]
[left]#worldUnitsTab
[/left]
[left]#matrix3Tab
[/left]
[left]#stringTab
[/left]
[left]#filenameTab
[/left]
[left]#colorChannelTab
[/left]
[left]#timeTab
[/left]
[left]#radiobtnIndexTab
[/left]
[left]#materialTab
[/left]
[left]#texturemapTab
[/left]
[left]#bitmapTab
[/left]
[left]#nodeTab
[/left]
[left]#maxObjectTab

the listbox.items array would be stored in a #stringtab
[/left]

Thanks Pete.