Texture::write - creates garbage file if fail.
Sketchup 2017 / 2018 Windows 10
This is a minor bug.
If Texture::write fail, invalid (garbage) file is kept on disk.
tx = Sketchup.active_model.materials[0].texture
#<Sketchup::Texture:0x0001468d7eee90>
tx.write("C:/normal.gif")
true // -> valid file is created.
tx.write("C:/colorized.gif", true)
false // -> this fail (colorized file can't be saved as gif - not important but why?) but on disk there is invalid "colorized.gif" file only containing gif "magic" inside.
Update: (same for ImageRep)
ir = tx.image_rep(true)
#<Sketchup::ImageRep:0x000140a5ae4598>
ir.save_file("C:/color_from_rep.gif")
Error: #<RuntimeError: failed to save image>
<main>:in `save_file'
<main>:in `<main>'
SketchUp:1:in `eval'
Feature request is:
::write shouldn't create file on disk when fail.
@prachtan
I've been away from actively using SU for a while, and even then, I worked with external applications where 'model appearance' was not a concern. Hence, I've haven't worked much with texture images.
Anyway, I created a test for this issue, shown here. In your sample above, the 'normal.gif' file seems to be created. In my test (line 30) , false is returned.
Hate to ask, any idea what I've got wrong?
Thanks, Greg
Logged as SU-40224
Hi prachtan
This issue is resolved in SketchUp versions SU2024.0 and SU2025.0. Now valid file gets created using this tx.write("C:/colorized.gif", true) =>true
Could you please confirm that it's not an issue for you anymore?
Thanks Kalpana