[Plugin] Material Tools

Re: [Plugin] Material Tools

Postby hank » Wed Mar 21, 2018 2:33 pm

OK, figured out what is up with "List Textures in Console" I think...

I changed puts to print in the following def from Plugins/tt_material_tools/core.rb and it works in SU2018 (sorry ThomThom - I'm probably not supposed to be messing around in there!?). So general question... is puts no longer valid in 2018?

Code: Select all
def self.list_textures
    Sketchup.send_action('showRubyPanel:')
    # Collect textures and sort by size
    mats = Sketchup.active_model.materials.select { |m|
      !m.texture.nil?
    }
    mats.sort! { |a,b|
      size_a = a.texture.image_width * a.texture.image_height
      size_b = b.texture.image_width * b.texture.image_height
      size_b <=> size_a
    }
    # Print textures
    print "=== TEXTURE MATERIALS BY SIZE ==="
    buffer = ''
    mats.each { |m|
      next if m.texture.nil?
      t = m.texture
      size = t.image_width * t.image_height
      file = File.basename( t.filename )
      path = File.dirname( t.filename )
      #puts "#{m.display_name} - #{t.image_width}x#{t.image_height} - #{t.filename}"
      buffer << "#{m.display_name}\n"
      buffer << "  Size: #{t.image_width}x#{t.image_height} pixels\n"
      buffer << "  Size: #{self.readable_file_size(size*3, 2)} estimated uncompressed RGB\n"
      buffer << "  Size: #{self.readable_file_size(size*4, 2)} estimated uncompressed RGBA\n"
      if File.exist?( t.filename )
        disksize = File.size( t.filename )
        buffer << "  Size: #{self.readable_file_size(disksize, 2)} on disk\n"
      end
      buffer << "  File: #{file}\n"
      buffer << "  Path: #{path}\n"
    }
    print buffer
    print "---"
  end
0

hank 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Previous


 

Return to Plugins

Who is online

Users browsing this forum: stevere and 4 guests

Visit our sponsors: