Copy and paste text from MaxScript Listener in a .Txt
Hello! I have a small question to do all of you:
With a little script, I have a button that find the position of an object.
In Listener I see write the position es. pos: [66.4655,8.38055,0].
Now, how do I transfer the result of the listener to a text file and open it after pressing the button?
Action: Press button > open .txt (not listener) with the result print.
Thanks and I hope in your help!!
Comments
Hello there!
Hello there!
I am surfing internet from hours but i don't find nothing can answer my question
"How can i write a TXT file or a custom format file through maxscript?
I already know how to create a file in custom path
(
txt = "insert your text"
f = (createFile "C://users//giorgio//myfile.txt")
format txt to:f
)
but how can i write some lines inside it?
(I use 3dsmax 2012 x64)
Thanks in advance :)
Best regards from italy
Gio.
Hi, writing and reading stuff
Hi,
writing and reading stuff to and from files is explained in the HowTo section of the documentation, "How To ... Read/Write Geometry Data From/To Text File"
You might also look for "External File Access - Topics Index" , its an overview of topics that help you working with external files, the one dealing with reading files would be "FileStream Values", writing is explained in the tutorial in mentioned above.
Cheers
Never get low & slow & out of ideas
I dont know what version of
I dont know what version of Max you used.
In old versions only through DOS commands can create folder.
First search in Reference for makeDir() located in "External File Methods", and test it. Else search for DOSCommand() in "Executing External Commands and Programs".
And Marco suggestion is OK. Well, there is example:
my recent MAXScripts RSS (archive here)
Hi Anubis! I use
Hi Anubis!
I use 3DSMax2008.
In fact I have already started to see DOSCommand() to create folders but your example is the best way to understand better my problem :)
I try to understand this dark side of MAxScript!!!
Thanks again for your response and patience Anubis!
Hi Michele, folder in which
Hi Michele,
folder in which you try to create the file must exist.
Good luck!
my recent MAXScripts RSS (archive here)
In fact with the example
In fact with the example that I have written, the folder exists and all is well ... But if I need a script to other people, as I create a TEMP folder?
Which chapter of the Help MaxScript should I take as an example?
The suggestion that Marco is valid?
You Could you explain better how to create it?
With this problem I have really big problems!
Thanks Anubis to you suggestion! :)
Hi Marco! I have try the
Hi Marco!
I have try the your suggested but is there something wrong in creating the file...
If I write:
newTXT = createFile "C:\\TEMP\\test.txt"
I get this message
-- Runtime error: FileStream cannot create: C:\TEMP\test.txt
After reading most of the header of the help MaxScript, your suggestion is right but I do not understand why this error...
I bypassed the problem so:
out_file = ((GetDir #archives)+"/test.text")
newTXT = createFile out_file
...
...
ShellLaunch ((GetDir #archives)+"/test.text")""
Thanks again! :)
No prob. If you have any
No prob. If you have any more questions just ask.
Wow!! Very, very thanks
Wow!! Very, very thanks Marco!!! Is the thing that helps me a lot :)
Now study in more detail the section you suggested.
Really thanks a lot.
newTXT = createFile
newTXT = createFile "C:\\TEMP\\test.txt"
format "value X: % \n" $.pos.x to:newTXT
format "value Y: % \n" $.pos.y to:newTXT
format "value Z: % \n" $.pos.z to:newTXT
close newTXT
ShellLaunch "C:\\TEMP\\test.txt" ""
Make sure you select a box or something and run that. It should be pretty self-explanatory