Notifications
Clear all

[Closed] Baking gives "Error creating bitmap"

Hi!

I am making a script that includes a simple baking function, but so far I just get error messages when I’m trying to render a baked texture.

Is there anyone here who has experience in this and can help me find out what I’m doing wrong?

Here’s a snippet of code demonstrating what I’m trying to do:

 
Sphere radius:25 smooth:on segs:32 mapCoords:on pos:[0,0,0] isSelected:on
macros.run "Modifier Stack" "Convert_to_Poly"
 
bakeDiff = DiffuseMap()
bakeDiff.outputSzX = bakeDiff.outputSzY = 512
bakeDiff.fileType = "tga"
bakeDiff.fileName = "C:\	est.tga"
$.addBakeElement bakeDiff
$.bakeEnabled = on
$.flags = 1
$.bakeChannel = 1
$.nDilations = 2

bakeBitMap = bitmap 512 512
render rendertype:#bakeSelected outputSize:[512,512] on:bakeBitmap vfb:on
undisplay bakeBitMap

If you put this into the listener, you will see that it renders the bitmap OK – but when it’s time to save – the message “Error creating bitmap” appears. There doesn’t seem to be anything wrong with the render part (it’s rendering after all, and I can save the resulting bitmap manually), so I guess there’s something wrong in the way I create the bake elements.

The max5 maxscript manual is a bit lacking in this, so I would really appreciate any input!!

Thanks,
Rune

16 Replies

I have this problem too. I’m not writing a script but just trying to use R2T and every time it will start out working ok then I get that same error…“error creating bitmap”. I can’t figure out why.

Did you by any chance ever figure it out?

I’m doing a new baking script at the moment, and I still keep on getting the message – so there’s no solution from me yet I’m afraid 🙁

Rune

I have no idea if this is the reason, or indeed even if you change it it will work, but in the line:

bakeDiff.fileName = “C:\ est.tga”
…why is there a double “\” instead of “C:” or ” [[\C:](file:///C:)](file:///C:) ” ?

because I get a windows error on this.

The reason for the double-slash is quite simple. “” is used as an escape in many programming and scripting languages, including Maxscript. You use the “” to access things like new line (“
“) and dashes (”””), and that’s why you have to use a double set of slashes to get a single slash in your string.

So a string that says:

fileString = "\"d:\\Program Files\\\"" 

Will be interpreted as:

"d:\Program Files\"

I think you can use forward slashes (/) as well in maxscript. But since the DOS Prompt doesn’t work with those, I think it’s best to stick to backward slashes for compatability with DOSCommand functions and such.

Rune

ive tried to add

outputfile:“D:\ est.tga”

at the render line, it will still hav an error but the file will be created (I also disabled the BakeDiff filename and filetype…

I also tried adding setting

SetSilentMode True

but it doesnt seem to work.
hmm… i wonder why i can’t search for the “#bakeSelected” word in the maxscript help. But when i opened up the Render to Texture macro, its all over the render line.

I hope this helps, though I wasnt able to fix the error problem…

I really want that error message to go away, but I’ll play more around with that part of the script this weekend. There is a freeware baking script that does this without any error messages, I’ll try to dissect that one to try and find out how it works!

®

im getting the same error in render to texture today at 4096×4096 (8192×8192 wont even start rendering). 30 gigs free on c and 22 gigs free on destination drive. p4 3.0ghz, 1gb ddr, geforce fx5700le… what do i need to do so i can render this thing out? now its holding up my project :P.

I can’t explain this, but the problem seems to be in the .fileName property. Very weird, but it seems to work if you use .fileType instead of .fileName :hmm:

-- create test object
Sphere radius:25 smooth:on segs:32 mapCoords:on pos:[0,0,0] isSelected:on
convertTo $ editable_poly
-- create bake element
bakeDiff = DiffuseMap()
bakeDiff.outputSzX = bakeDiff.outputSzY = 512
bakeDiff.fileType = "C:\	est.tga" -- I have NO idea why this works ??
-- set bake properties
$.INodeBakeProperties.addBakeElement bakeDiff
$.INodeBakeProperties.bakeEnabled = on
$.INodeBakeProperties.flags = 1
$.INodeBakeProperties.bakeChannel = 1
$.INodeBakeProperties.nDilations = 2
-- bake! .. show vfb and undisplay when done
undisplay (render rendertype:#bakeSelected outputSize:[512,512] vfb:on)
-- delete test object
delete $
-- open saved file
shelllaunch "C:\	est.tga" ""

I just got a strange feeling of Deja Vu. I’m wondering if someone already answered this at discreet support in February. I just can’t remember, and I can’t fint the post either.

My script is larger and more complex than this example, but I’ll try fixing it and see if the error goes away

Thanks!
Rune

Page 1 / 2