if live_scene = VRay::LiveScene.active materials = live_scene.model.materials model_dirname = File.dirname(live_scene.model.path) model_name = File.basename(live_scene.model.path, ".skp") texture_workspace = "#{model_dirname}/#{model_name}_Textures" FileUtils.mkdir_p(texture_workspace) VRay::Callbacks.without{ live_scene.grep(:BitmapBuffer).each{|bitmap_buffer| next if File.exist?(live_scene.find_file(bitmap_buffer[:file])) display_name = bitmap_buffer.name[/[^\/][^\/]*/] if skp_material = materials.find{|m| m.display_name == display_name} if texture = skp_material.texture bitmapbuffer_basename = File.basename(bitmap_buffer[:file]) texture_basename = File.basename(texture.filename) if texture_basename == bitmapbuffer_basename new_file = "#{texture_workspace}/#{texture_basename}" texture.write(new_file) bitmap_buffer[:file] = new_file end end end } } end