Notifications
Clear all

[Closed] System Exception? Why?

Hi, is there a maximum file size for a filestream?
This script give me a System exception error if I open the
file as is. If I just remove some data and resave it it’s working…

fileNameDXF = “d:/iso2.dxf”
fs = openFile fileNameDXF mode:“r”
content = readChars fs (getFileSize fileNameDXF) errorAtEOF:false
close fs –close fileStream

Try to open this file: http://www.urbanimage.ca/upload/iso2.zip

Regards,

OZRay

6 Replies
1 Reply
(@zeboxx2)
Joined: 11 months ago

Posts: 0

Possibly, but I don’t think that’s it…

.
Presumably, maxscript tries to allocate a particular size buffer and that buffer has a limit for how big it can be. That’s why it fails immediately, instead of spending quite some time reading (I just tried with 1,000,000 characters… it’s still going*).

  • Edit: Whoops. That would be because it’s printing everything to The Listener with the code given ‘as is’. Stuck it inside a function and returning OK now so it won’t be doing that, and it’s much faster. That said, I tried 1040000 characters and 3ds Max disappeared.

How big does the file end up after you remove ‘some data’?

In case it’s worth anything… I also tried…


   strStream = stringStream ""
   while (not (eof fs)) do ( format "%
" (readLine fs) to:strStream )
   

Which finished fairly quickly*. Not sure if that gives the exact same result, however.
Edit: initially compared to the readChars that printed everything out to the listener, which was sloooooow.

Thanks, my files can be between 5Mb to 18Mb to process…

I tried to implement your stringStream but max take forever to process my file…

What Im trying to do is to replace some character in those file before importing it, cause the
file is not valid I need to replace some of the caracter in it… Maybe the faster way
will be to use a commandline tool to process it…

Regards,

readChars is very slow. I do lots of reading of files and replacing certain things. Generally it is the same process (pseudocode):


f = openFile filePath mode:"r"
tempStr = stringstream ""
while not eof f do
(
	local l = readline f
	if (matchPattern l pattern:"*patternToMatch*" == true) then
	(
		local newLine = ...--process l here
		format "%
" newLine to:tempStr
	)
	else format "%
" l to:tempStr
)

close f

f = openFile filePath mode:"w"
format "%" tempStr to:f
close f

I’ve done some big files and never had a problem. Make a progressbar to track your progress, if you want.

if all you -are- doing is search&replace, though… yes, a command-line utility is probably much faster. Could try with some .net as well, but given the plurality of S&R command-line utils out there… unless there’s a distribution issue …’d go with one of those for biiig files.

I had a problem with reading a large file (4GB file) and used the +rb option for binary and parsed it from there. It was a bit more stable.

May or may not help.

1 Reply
(@ozray)
Joined: 11 months ago

Posts: 0

Thanks everyone,
at the moment it’s working with the command-line utility called ssr.exe but
a more elegant way will be directly with MSX not depending on other stuff.
So I will give a try to what’s Professor420 suggest.

Regards,

OZRay