More value Spinner in a Loop

Hello man!

I have a curiosity:

I have 3 spinner named Spinner1, Spinner2 and Spinner3 and they control three parameters.

I have this loop (for example)

[CODE]
for i in scenematerial do (temp = spinner[i].value print temp)
[/CODE]

it's possible "pass" the [i] for all three parameters of the spinner?

If possible How do? Contrariwise there is another solution?

Thanks for any help :)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

...

'i' in your example is not a number but material.

for i = 1 to scenematerial.count do print (spinner[i].value)

This will throw error if scenematerial.count > number of spinners
Be more specific. What's represent spinners value, which parameter?

barigazy

Michele71's picture

Thanks for you reply Barigazy

Thanks for you reply Barigazy :)

Yes you have right :) I'm confused!! but still wanted to be a simple example :)

The concept is this:

I have write a script that controls the parameters "Blur" in the any material in VRay.
Now, I have more of the 53 spinner (spnBlur1, spnBlur2, spnBlur3, ...) with related controls
I must write in a .text file, the value of each spinner control then, the values ​​of material "Blur".

There is a method to write a loop that allows me to do this?

thanks in advance :D

barigazy's picture

...

This is very easy using .net
Just be sure that your rollout is open and name of rollout is stored in global variable.
You can do this simply adding this line at the top of your code

try(destroyDialog ::roll)cache()

Next we need to define some .net classes

dnSW = dotNetClass "System.IO.StreamWriter"
dnFile = dotnetClass "System.IO.File"
myTxt = dotNetObject dnSW (dnFile.Create @"c:\Users\Public\Documents\WriteText.txt") --change filename for your case
for c in roll.controls do -- i used "roll" for rollout 
(
	if isKindOf c SpinnerControl and MatchPattern c.name pattern:"spnBlur*" do myTxt.WriteLine (c.value as string)
)
myTxt.Close() ; myTxt.Dispose()
-- next line is only if you want to see saved file in mxs editor
edit @"c:\Users\Public\Documents\WriteText.txt"

barigazy

Michele71's picture

WoW!! Hahahahah thank you

WoW!! Hahahahah thank you barigazy !! it works!!!! hahahahha :)

Unfortunately I have never used .Net :(
Your solution for me is a big help and certainly a starting point to begin to study the .net :)

Thank Again barigazy! 1000+ point! :D

barigazy's picture

...

Or as function

fn storeRollSpnValuesToTxt roll ctrlClass: patt: txtFileName: =
(
	local dnSW = dotNetClass "System.IO.StreamWriter"
	local dnFile = dotnetClass "System.IO.File"
	local myTxt = dotNetObject dnSW (dnFile.Create txtFileName)
	for c in roll.controls where (isKindOf c ctrlClass and MatchPattern c.name pattern:patt) do myTxt.WriteLine (c.value as string)
	myTxt.Close() ; myTxt.Dispose() ; gc light:on ; txtFileName
)
storeRollSpnValuesToTxt someRollout ctrlClass:SpinnerControl patt:"spnBlur*" txtFileName:@"c:\Users\Public\Documents\blurValues.txt

barigazy

Michele71's picture

Many thanks barigazy :) This

Many thanks barigazy :) This Function is VERY helpful ;) double-inch!!! :D

barigazy's picture

...

Probably next question will be how to read back theses values or how .net "StrimReader" works.:) While back I created simple TextEditor where I used same methods.

barigazy

Michele71's picture

Hahahaahah Probably so, but

Hahahaahah Probably so, but for now this is already a lot! :D If I have a problem with .Net I make a whistle! hahahahah

Thanks Again :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.