Massmaterialimportant.rb woes
-
hi tig,
i am having a little problem with this script. it works fine as far as importing goes.
i am trying to import a number of wood textures into a skp file. the problem i am having is that no matter what texture i choose to import it keeps importing the first one.
is there a solution for that? or, am i doing something wrong?
cheers.
-
This is the entire code [I tweaked it almost two years ago...]
#This script was created by Adam Beazley for public use and may be edited. #http://www.abeazleydesign.com #Directions #Just click in the Import Materials button in the plugins menu and type in the location of all of you image files. #This script will create a material and name it the same name as the image file and then use that file as the texture. #all textures will come in at a standard scale and must be edited later #after all materials and textures have been imported into the model, simply add them to your library #you can then save the library as a .skm library file through sketchup. #have fun!!! # ### v1.1 TIG tweaks 29/12/05 ### #----------------------------------------------------------------------------- require 'sketchup.rb' #----------------------------------------------------------------------------- def materialimporter model= Sketchup.active_model materials= model.materials model.start_operation ("Import Materials") ###undo - see commit at end pwd= Dir.getwd.split("/").join("\\")+"\\" ### fix for SU dry= UI.openpanel "To Pick this Directory; Pick Any Image File + OK...", pwd , "*.???" ### for jpg or png return nil if not dry dry= File.dirname(dry) return nil if not dry cwd= Dir.chdir(dry) images= Dir["*.{jpg,png,tif,bmp,gif,tga,epx}"]### for all supported image file types for image in images imgname= image.split(".")[0..-2].join(".") ### removes .jpg etc from end mat= materials.add imgname mat.texture= image end#for image### model.commit_operation ###undo all if needed end#def### if(not file_loaded?("massmaterialimporter.rb")) menu=UI.menu("Plugins") menu.add_separator menu.add_item("Import Materials") { materialimporter } end #----------------------------------------------------------------------------- file_loaded("massmaterialimporter.rb") #
Works fine for me ?
-
This may have nothing to do with it but I have been burned using this type of code before:
imgname= image.split(".")[0..-2].join(".") ### removes .jpg etc from end
Maybe he is using weird filenames that aren't properly handled by this code. (eg. "my.texture.jpeg")
Can you post the names of the files you are trying to import?
-
better than that, i will post the files.
Advertisement