Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / MaxScript 2012 won't format string to external file
  RSS 2.0 ATOM  

MaxScript 2012 won't format string to external file
Rate this thread
 
64175
 
Permlink of this thread  
avatar
  • Total Posts: 1
  • Joined: 27 July 2011 08:41 AM

Hello everyone!

In a need to use this code:

file = (createfile  "C:\Users\Relja\Desktop\\filename.txt")
format "mystring" to:file

I’ve found out that it’s not working in 3ds Max 2012. Works fine in 2010, but in 2012, compiler says “OK” but nothing gets formatted to the file.

I’ve looked under the MAXScript Help on the web, but they say nothing about changing this command.

If anyone knows a solution, I would appreciate if you’d share.

Thanks!



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

Moved from Max2012 - you’ll get better responses by posting in the most appropriate forum for the question.

First off - be careful with variable names, avoid any names which may conflict with built-in variables/functions.

Second - you should be testing the result of the createFile to see if it worked.

Finally, backslashes in filenames have always been problematic - sometimes they work and sometimes they don’t. Avoid such issues by either using 2 of them, or by using a single forward slash.

myFile createfile "C:/Users/Relja/Desktop/filename.txt"
if myFile != undefined then
   format 
"mystring" to:myFile
else
   
messageBox "Error: File open failed"


Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 0
avatar
  • gimik
  • Posted: 21 February 2012 09:54 AM

there was change to maxscript filestreams in max 2012.  the stream isn’t actually written until the file is closed.  steve’s code is best practice, but you will also need to execute a close command before trying to look at the file:

myFile createfile "C:/Users/Relja/Desktop/filename.txt"
if myFile != undefined then (
   
format "mystring" to:myFile
   close myFile
)

greg



Replies: 0