I have a model which when imported with textures is 56MB, when imported without textures is 25MB.
The difference in file size is not due to the images, which total only 100KB, instead, the difference is due to each face now having an array of positions and UV coordinates per vertex.
I want to work with the textured model, over-paint with basic colours, and then later remove the textures. However, when I remove the textures, the file size is still 56MB less the 100KB or so for the images.
The only solution that I’ve found so far is to export the model after painting with basic colours, and then re-import. But I’d prefer a ruby-script solution if possible.
Nothing happens if I remove the textures programmatically like you suggest, the model already contains no textures as I have deleted them from the materials.
The problem is the faces somehow maintains their UV coordinates, even if the face material is set to nil.
I finally found a programmatic way to remove the texture coordinate positions from a face, it is not an elegant solution, but I’m posting here in case anyone else encounters the same problem (as we should).
The solution
For each face that does not have a texture, i.e. face.material.texture == nil
I need to delete the face, then recreate it.
points = []
face.outer_loop.vertices.each { |vert|
points.push(vert.position)
}
mat = face.material
face.erase!
face = entities.add_face points
face.material = mat
face.back_material = mat
Thats all there is to it!
The file now saves without the bloated overhead of including the UV coordinates with each face.
[Edit: Sketchup should be removing the unused texture coordinates during a ‘Purge Unused’ operation]