Notifications
Clear all

[Closed] Problem with write to text file in 3dsmax 2012

i tried use maxscript 2012 to write a special to text file, but it is not working
ex: i have a scene and have some object, i select one object and coding below script


f = createFile "D:\\bao\	ext.txt"
format "%n" $.name to: f

but this script is not working
can i help you

4 Replies

possible some windows administration permission denied, try to run 3dstudio with admin privilege, or try do create the correct folder without “only read” permission. Maxscript 2012 is equal to 2011

/* Test.ms */
filename = getFilenamePath (getSourceFileName()) + "test.txt"
file = createFile filename
if file==undefined then messagebox "Wrong location or no admin permission or something don't work"
Close file -- the file must be closed to unlocking it

You should check that you are using SP2.

The vanilla install of 2012 had a bad bug where it locked files created by MAXScript. It didn’t stop MAXScript from writing… but the files would be locked from other processes until Max shuts down.

Hopefully that helps.

1 Reply
(@johnwhile)
Joined: 10 months ago

Posts: 0

also in maxscript 2011 i encountered this bug, some time i used “gc light:on” to clear garbage collection, but now my tool create everytime a file called “j” and 1,6 MB without extension …

Have you tried opening the file for writing?

fName = "ahosking.text"
if (doesFileExist fName) == false then	--if the file does not exist, create it
(
	createFile fName	--creates the file
	fs = openFile fName mode:"r+"   --opens the file
	format "Write my text to file!
" to:fs   --this writes your text to the now open file

)

flush fs	--clear the file from memory
close fs	--close the file stream