Notifications
Clear all

[Closed] scene objet txt list

hi people,
I want to export a object list of the scene in a text file. Anyone ever done this?
thank you

6 Replies
(
  	local infoFileSavePath = (GetDir #export)
  	local checkInfoFile = infoFileSavePath+"\Statistic.txt"
  	if doesFileExist checkInfoFile then
  		infoFile = openFile checkInfoFile mode:"at"
  	else	--	if infoFile does not exist - create it
  		infoFile = createfile (infoFileSavePath+"\Statistic.txt")
  
  	for o in objects do
  		format "Name: %
" o.name to:infoFile

[b]flush infoFole[/b]
close infoFile
  )

The file with name Statistic will be created in max “export” folder.

don’t forget to flush and close the file stream

Oh, yes.
This snipet is from one of script that i.m working now, and the close, flush and gc() are at the bottom of the script(about 100 lines below).
The above code is updated.

Why do you need to Flush before closing? Doesn’t Close Flush anyway?

From maxscript help…

[left]flush <filestream>
[/left]
[left]Ensure all output to file is on disk, flushes the memory buffers.
[/left]
[left]close <filestream>
[/left]
[left]Flushes the memory buffers and closes the file
[/left]

Thank you guys!

If you don’t want to open the file first you can also use getMaxFileObjectNames max_filename_string> [ quiet:<bool> ], to get the list of object names.

-Eric