Ruby script to extract instance name to csv

HI all, I am fairly new to Ruby scripting but am very versed in SketchUp, I have been using it since @Last. I use Sketchup Daily in my job and I want to automate what I think is a few simple things. I build cabinets using cabinetsense plug in and I also use it to design kitchens that I order ready to assemble (RTA). I want to retrieve the instance name of all the cabinets that I select and have the populate a csv file and then I can manipulate that into my quoting and ordering software.

I have been using one of the Ruby code editor plugins and learning Ruby for SketchUp and have made a few scripts to do things such as draw things and automate scenes, but I just cant seem to do what I want when it comes to exporting info. If anyone has an example of what I want or can point me to a place I can find it, that would be great.

Thank you,

Matt

Look at this for ideas…
https://sketchucation.com/pluginstore?pln=ComponentReporter
It probably does more than you need, so I’d just extract the bits you want…
It’s a bit old and clunky but does what you want…

1 Like

Thanks TIG, I have been able to get what I want but when it outputs I get apostrophe marks ’ ’ around my data in the csv file. Is there a way to get rid of those?

Most probably yes. But without seeing your code and/or a generated csv file … we do not have soo much chance to guess… :blush:

1 Like

I just posted a simple example …

1 Like

dezmo , TIG has the code posted right above my last post.

Thanks Dan, I will take a look when I get back to my shop this afternoon.

Check e.g. line 138 (and similar lines below this line) in a code.

   dname="'"+c.definition.name.tr(",",";")+"'"

The (apostrophe) character intentionally added to the string.
You can edit the code to remove these.

Alternatively

(Alternatively in EXCEL : you can use Find and Replace (Ctrl+F) to replace it easily :wink: )

1 Like