Mass Material Importer

General discussion related to SketchUp Pro and Make

Mass Material Importer

Postby dillow » Wed Jun 07, 2017 11:17 pm

My old computer (the one with all my materials libraries on them) took a dump. I now need to recreate the materials folders. I seem to be having trouble getting the old Mass Material Importer plug-in to work. It loads and asks for a file location, I enter that, and then nothing.

Is there a way to batch do this outside of the old plug-in? It is way too tedious doing this one at a time. I find it hard to believe there's nothing in the warehouse that accomplishes this. It's got to be one of the most basic plug-ins.

Thanks!
0

dillow 
 

Re: Mass Material Importer

Postby Rich O Brien » Thu Jun 08, 2017 9:49 am

Do you need to add .skm files back to SketchUp as collections?

If you have your original .skm files then is is relatively quick to setup new collection in SketchUp.

PS...
What concerns me more is that your old PC took a dump. :shock:
1
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

Re: Mass Material Importer

Postby dillow » Thu Jun 08, 2017 1:39 pm

I do not have the skm collections. I do have old Sketchup files with materials in them but I thought it'd be just easier to download the jpgs (mostly from manufacturer tileable images). But converting hundreds of jpgs to skms isn't fun.
0

dillow 
 

Re: Mass Material Importer

Postby sdmitch » Thu Jun 08, 2017 3:30 pm

dillow wrote:I do not have the skm collections. I do have old Sketchup files with materials in them but I thought it'd be just easier to download the jpgs (mostly from manufacturer tileable images). But converting hundreds of jpgs to skis isn't fun.


Here is a version of the method I use to load materials into a model.


Code: Select all
module DILLOW
      def self.materials_from_file
         @mod = Sketchup.active_model
         @textures_from_file = []; @images = []; @image_path ||= File.dirname(__FILE__)+"/*.*"
         @image_path = UI.openpanel("Texture Files",@image_path)
         unless @image_path==nil
            image_folder = File.dirname(@image_path.gsub('\\','/'));
            @images = Dir[image_folder+"/*.{jpg,png,tif,bmp,gif,tga,epx}"]
            @images.each{|i| @textures_from_file<<File.basename(i,'.*')};
            if @textures_from_file[0]
               @textures_from_file.each_with_index{|name,i|
                  unless @mod.materials[name]
                     mat = @mod.materials.add(name)
                     mat.texture = @images[i]
                  end
               }
            end
         end
      end
end
DILLOW.materials_from_file


Copy and paste into Ruby Console and press Enter to execute. Select any image file and click Open.
0
Nothing is worthless, it can always be used as a bad example.

http://sdmitch.blogspot.com/
User avatar
sdmitch 
PluginStore Author
PluginStore Author
 

Re: Mass Material Importer

Postby ronaldoluidi » Wed Jun 06, 2018 6:05 am

sdmitch your code is awesome, thank you!
0

ronaldoluidi 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to SketchUp Pro & Make Discussions

Who is online

Users browsing this forum: garbegot and 3 guests

Visit our sponsors: