1

im new here and pretty much brand new to ruby. I am using ruby to write sketchup plugins with the Sketchup module, and i want to import all the image files (textures) from the directory 'C:\Users\(your name)\Pictures\sketchup-textures' and put them into the material list in sketchup, so that i can put them onto my models.

I know that there is a way of manually doing this, but I often need to handle a lot of textures at once, and want to automate the proccess. THANKS!

EDIT:I know i can do this, but it only does one file at a time and only the one i code.

m = materials.add "test1"
m2 = materials.add "test2"
m.texture = "c:\\Users\\(yourname)\\Pictures\\(file).png"
m2.texture = "c:\\Users\\(yourname)\\Pictures\\(file).jpg"
texture = m.texture = "c:\\Users\\(yourname)\\Pictures\\(images).png"
if (texture)
  UI.messagebox texture
else
  UI.messagebox "Failure"
end
help1234
  • 23
  • 6
  • So, you want to know how to iterate over all files in some directory? Probably [this](http://stackoverflow.com/q/6166103/693538) question might help you? – NIA Jan 23 '13 at 17:18
  • Kind of - It seems that you state directories differetly with the sketchup module though. The bit I really need is the bit of code that loads the textures into sketchup. – help1234 Jan 23 '13 at 17:29
  • It's been done. [massmaterialimporter.rb](http://rhin.crai.archi.fr/rld/plugin_details.php?id=241) and [discussion](http://sketchucation.com/forums/viewtopic.php?f=180&t=17857) – Jim Jan 25 '13 at 12:00
  • Thanks, I couldn't find this in english. – help1234 Jan 27 '13 at 09:58

0 Answers0