Hi all :)
They are the last details of my script (Environment Lighting HDR Studio (MR) ) but now I've a problem that I can not solve...
I want to enter parameters in rollut taking them from a txt file, but the info in file txt are written as Reflections (Subactive Color): (color 255 255 255) or Glossines: 8.0 ecc.. Now I know this form to isolate number from string array:
test = "Max Distance FallOff: 2.0"
strArr = filterString test " "
valuespinner = strArr[4] as float
print valuespinner
but I can not transfer ONLY values in rollout, because I always error of various kinds (!)
If I try with "openFile" and "readValue", (for read the file txt) I've always the result, for example, "scale()", but never specific value. I had no trouble writing values to and from .txt, but now I can not do this..
The question is very simple: How isolate a number from a string with quote "" and restore the values of spinner etc. the rollout reading a file .txt?
Any help is very important to me :D
Thanks
Michele71
By
Comments (28)
Comment policy
Thanks for the stuff. it is more like a gift for me to have such content as being fond of the codes.
Thanks barigazy for the link.
My programming is really basic ( :D ) and anything that can increase the information and study is well accepted! I find Dotnet too difficult for me now...
Thanks for the help and valuable resources!!
Well, with the FN of Barigazy I've solved many parameters that work very well, while for the pickcolor, don't find solution. The suggestion of pixamoon
does not work. With the fn I have always the result of 0.0...
I keep (work permitting) to seek solution :)
ah, because last value has ")" -> "127.5)"
you need to remove ")" and then convert to float
`
something like this: ?
WoW! thanks, now try it! :)
`
great :)
but this is starting to be complicated reading, maybe it will be better to format differently on save so you get: (with "|" quote)
name|value
or for color
name|value|value|value <- format "%|%|%|%" a.name a.color.red a.color.green a.color.blue
Than will be very easy to read single values
Hahahahah yes, you're right :D
Unfortunately took an unexpected direction, I did not think of creating a command to reload for spinner, but I am learning a lot from this.
However your advice WORK and I am very happy, even if it is a bit "confusing" :)
Thanks a lot! really !!
`
yes, me too. this was nice brain training :)
One more idea for saving settings is .ini file. But you know this probably.
It looks very easy with code:
setINISetting IniFIle "Settings" "glossines" (value as string)
getINISetting IniFile "Settings" "glossines"
I think I'll be using ini or xml :)
Best,
*.Ini is good solution to store this kind of params. But XML is much fester,
especially when you use XPath method for reading XML doc.
Maybe you already know for this site.
XML examples
http://www.w3schools.com/xml/
XPath examples
http://www.w3schools.com/xpath/
You can find also example
http://www.scriptspot.com/forums/3ds-max/general-scripting/manipulate-xm…
`
wow, great examples and tutorials lol, thank you !
I would say .ini is good for just few values to save / load (because easy single lines to get and set values in code)
And for larger amount settings /data -> definitely faster XML !
What you think ?
that's right
;)
`
:)
Thank you again for XML examples... I still need to learn this, I have few ideas where to use it, but didn't have time to learn it. Now will be very easy.
Thank you !
`
ah, and the last thing I saw somewhere to convert string to Poin3 but it works with color too!
then it can be much easier to get color form your text file:
But if you have ini file it will be so easy to convert string "(color 10 10 10)" to color value.
Sorry I forgot about it yesterday.
Best,
`
and even better:
this is what I found in maxscript help about execute
and
maxscript sample:
and this should be very easy to read from txt file :)
Heheheheh I have noticed of this :D The problem is that then the development there is always something wrong... your advice anyway are very useful, I discovered things I did not know :) thanks!!!
Also to store some data of any tool (read/write) the best and fastest way will be XML.
Yup. Can be done with .net but ...
test = "Max Distance FallOff: 2.0"
fn extractValue string asFloat:on nums:"1234567890." =
(
name = trimright (trimleft string nums) nums
string = substituteString string name ""
if asFloat then string as float else string
)
extractValue test
Thanks barigazy, I try your function :)
At this point I agree with you as regards the format xml....
Thanks Again!!
`
why not go with loop and case (of course after filtering)
so if you have strArr array:
just an idea.
value is always next after name
and "Glossines:" u have probably as a rollout elements .text
It doesn't work for color but than you can do
ah but u need to have written in file "Glossy_Sample" instead of "Glossy Sample"
or remove spaces before writing so you get "GlossySample"
Thanks pixamoon :)
Before posting my question, I have tried a simil loop, but without success. Now I perform also your advice and see what appears!
Thanks for your patience and response :)
sure
thats the 1st way (loop every line to get values):
and this is 2nd (append all single words to one array and than loop it and search for values)
Of course you need single words, like "Glossines:", "GlossySample" etc
What you think ?
Yea, I'm doing the tests, but I think the concept is right ;) I try to do the tests then I'll know!
thanks again!!!!
reading form txt
I think dotnet methods will help
Maybe this will help. Take a look on http://www.scriptspot.com/3ds-max/scripts/read-data-from-csv-txt
the quote there is "|" but you can easily change to other quote I think.
Best,
Yes pixamoon, I have already read that discussion, but I was not help ... I thank you anyway for your attention and response :)
`
I'm bit not sure how and which values you want to get from txt file.
I dont understand where you get "scale()" etc. instead of value...
Can you post or send me part of this txt file ? pixamoon@gmail.com
Sure! I attach here the file exemple file .txt
What is on in rollout is printed in the .txt file, so not everything is written (plese see Environment Lighting HDR Studio (MR) to understand the working). The value to get from .txt is number and true or false (to send in spinner rollout ecc).
Attachments