[Closed] Access Range of parameter on CA?
How can I access the range of a spinner’s parameters in a custom attribute that I haven’t scripted myself?
I thought this would be dead easy, but I can’t get to the spinner’s name in any usable generated code.
I did this a few days ago with the value property.
You could use custAttributes.getDefSource <attrib_def> to see the code. Then access the range with CA.RolloutName.SpinnerName.range
Yep. Something like this if you use EmptyModifier to store CA
Attr = custAttributes.getDef $.modifiers[1] 1
Attr.source
If you are accessing a definition that was written using the Attribute Editor it will store creation information about the definition in defData. That data will hold values like the range of a spinner since you can’t access that via the parameter.
there is a puzzle. let’s say you have only source of scripted CA. We don’t know the name of the spinner. how to find it in the source?
Well in my case the spinner was labeled “IK-FK Blend” so I just searched for that in the source. But I guess you could do this on the rollout:
roll = myRollout
for i = 1 to roll.controls.count do
(
--SEEMS TO CRASH ON GROUP CONTROLS
try
(
format "%: %
" (roll.controls[i].caption) (roll.controls[i].name)
)
catch()
)
I don’t know if it helps but I had something similar to do a few weeks ago and I parsed the CA defSource string to find the items array of a dropdownlist.
I didn’t find any other solution to that and wait to see more efficient ways to do it :).
AFAIK, you can find some useful props of the CA with “getPBlockDefs”, like default value, but not all options of the CA parameters.
I hope someone will make me wrong :).
The problem I have with all these methods like parsing is that they require visual inspection.I need a completely coded soultion
I don’t know if this works in every situation, but it seems to work in all the ones I encounter:
Attr = custAttributes.getDef $.modifiers[1] 1
arrayd =custAttributes.getPBlockDefs Attr
caname = Attr.name ;
rolloutname = arrayd[1][4][2] as string;
for j = 5 to arrayd[1].count do (
paramername = arrayd[1][j][2][4][1] as string;
range = execute( "$.modifiers[1]."+caname+"."+rolloutname+"."+paramername+".range")
print range[1];
print range[2]
Basically it’s Branco’s method made explicit.I’d be interested if anyone finds that this fails sometimes. Does this solve yr puzzle denis?
Seems better than source parsing, indeed.
And it does not require to know parameters name in advance, like you said before.
Thank you