[SOLVED] Playing with 2 dialogs [one main and one for editing variables]
-- Messing with \ and \\ -- [SOLVED] But another question at the bottom
Hi there, this is my first post here, and i'm a beginner in maxscript, and scripting in general.
I'm currently improving my script so it can store configuration file, and use them as variables.
I have several problem which i can't solve on my own, and, as a French young man, my english is not good enough to understand the all Maxscript Help File.
I'm Asking for help :)
So i learn there is scope things to access variables in different loop, and it's a bit hazy for me. I think It's on problem i have in my script, but first, i have a problem when edit my .ini file:
>> I must store a Network Path into my Ini File, but i just notice that the function "SetINISetting" simply ignore multiple backslash:
in my functions.ms file:
setINISetting theoutput "folders" "dossier_portes_ini" "\\\\Averty\\v\\Oskab\\scenes\\_portes\\" setINISetting theoutput "folders" "dossier_render_ini" "\\\\Averty\\v\\Oskab\\scenes\\__RENDER\\"
in my .ini file i get:
[folders] dossier_portes_ini=\\Averty\v\Oskab\scenes\_portes\ dossier_render_ini=\\Averty\v\Oskab\scenes\__RENDER\
But when I re-use my editvar rollout and manually type the good path,I get the good one... This is a mystery for me...
I need this function to work, because it's the defaults settings, overriding the one missing, or use as default if no modification are made.
Thanks in advance for reading me, and a thousand thanks for trying to help.
-- EDIT --
I'll try to be clear explaining this one !
First, i had only one roullout "main", opening when starting the script with everything in It, it worked well, but i like challenge and for further use, i wanted it to be editable.
So, now i have 3 files; main.ms, functions.ms and editvar.ms
main call editvar.ms by pressing a button, and when editvar close, it store all information into a temp.ini so i can access to my variables easily into main.ms
My problem is that when main start, it create a dropdownlist by parsing a folder, which can be modified by the second rollout.
since the dropdownlist is created when the first roullout is called, when i close my edit var, i don't find a way to update it (i tried "on close" but when i call it in the main script, it's gone since a long time and it does nothing)
So, for now, i close everything and launch the script again... not very handy !
Main:
http://my.jetscreenshot.com/8140/20130907-p6qh-26kb.jpg
EditVar:
http://my.jetscreenshot.com/8140/20130907-qazg-78kb.jpg
Thanks Again for helping me :)
[EDIT 2013/09/04]
-------------------------------------------
Some Handy Functions I use In this script:
1) LISTNG FILES: Create a list of files To put in a DropdownList / ListBox / MultiListBox: Arguments: Directory (path to folder) / Extension (ex: "max") / Extensionlength: number of character in Extension (ex: 3) / directorylengtplus = 1 for network path (UNC) or 2 for classic path (C:\\...) [ I use one Checkbox for It] / the dropdownlist: name of the object UI.
fn listingfiles directory extension extensionlength directorylenghtplus thedropdownlist = ( listeporte = getfiles (directory + "\*." + extension) /*Creating 2 empty arrays listetemp holds thefilename + extension liste holds filename without the extension.*/ liste = #() listetemp = #() for a = 1 to listeporte.count do ( directorylenght = directory.count listetemp [a] = Substring listeporte[a] (directorylenght +directorylenghtplus) 100 counttemp = listetemp [a].count liste [a] = Substring listetemp [a] 1 (counttemp - (extensionlength+1)) ) for a = 1 to liste.count do ( thedropdownlist.items = append thedropdownlist.items (liste[a] as string) ) )
2) Bdigit nb: Return a number value into a String with 4 digits:
fn bdigit nb = ( tostring = nb as string countstring = tostring.count if countstring == 4 then result = tostring if countstring == 3 then result = ("0" + tostring) if countstring == 2 then result = ("00" + tostring) if countstring == 1 then result = ("000" + tostring) return (result) )
Comments
It's A Succes !!
Many Thanks barigazy, I just modify a little your code to set and get ini settings, It's Working !!
I have to make little adjustments to my main code to log my print information into a external file if asked by user to end this.
This make me won a huge amount of time at work. I'm already thinking about another script to improve my pipeline again.
The script is too specific to be posted and shared, but the functions could be used by others.
I will update the first post to share a few of them.
Thanks Again You Rock Man !
...
My pleasure. :)
bga
...
One more thing I forget to tell you abut struct.
You can load or create "ini" settings when strut is created using "on create" event.
Look at the code of this script where I write and load UI settings from XML file.
This is a bit advanced but U can use *.ini file in the same way.
http://www.scriptspot.com/3ds-max/scripts/scriptrun
bga
Organizing Is a good thing
It's working... for now.
I just re-organize my script, declare the 2 rollout in the same file, and simply close and open the main roullout when editvar close, the variable "folder" change and the dropdownlist is updated. It's dirty, close and open to update but it work...
I'll post handy functions after a few more tests :)
...
Sometime is better to pack all your stuff in one file for sure, u can use "struct" to organize your fn's and variables for easy acces.
bga
I Keep your source code aside
I Keep your source code aside for my next project. I hope i could share this one after use. Your Tips will be very handy then :). I must Learn DotNet classes.
I really appreciate your help Barigazy. I Have no good resources to learn maxscript on my own, and nobody's making fun with maxscript here... :) Thanks Again !
I know I have to Put functions into my forst post, I will, i promise, but now i have the script i have to use it since it's ready to produce images... That why i didn't reply sooner.
...
Shorter version of your 2nd fn
bga
...
Also 1st fn can be optimized but I not understand french :)
bga
Thanks again for the
Thanks again for the optimization ! :D I know that i have to avoid the return function, but i didn't know how to do it your way :D
I translate the text in the first function :p I have several more to add but i don't now if they can be usefull for others.
...
Now about 1st fn optimisation
I next example I will use .net method to collect all files in specified directory by given extension and extract only file name without extension (optional)
bga