Batch SKM library

Hi there,
Is there any way to get data from the excel sheet into .skm materials RGB-based?
Thanks!

Yes, this is possible using a Ruby script.

Wow, thanks! would you know somebody who knows how to?

CSV table example

You could create SketchUp materials based on CSV data in the following way:

require 'csv'
  
mod = Sketchup.active_model
mats = mod.materials
  
CSV.foreach(("C:/[PATH TO CSV]/rgb_materials.csv"), headers: true, col_sep: ";") do |row|
   new_material = mats.add(row[0])
   new_material.color = [row[1].to_i,row[2].to_i,row[3].to_i]
end

This is an example of one possibility.
It can of course be done in more ways.

1 Like

I’ve got this script here
I use a CSV with headers NAME, R,G,B

Run this in the ruby console and point it at the CSV and it will generate them - this is a modified version of another script- this particuarly one embeds some PBR paramters for rendering in enscape also

version = Sketchup.version.to_i osx = Sketchup.platform == :platform_os - Pastebin.com

1 Like