Populating components attribute options


#1

Continuing the discussion from How to get a sufficiently detailed image into the Component Options box?:

This can probably be done through the Ruby Console or with a script.

If you are comfortable with this, here’s a tutorial on attribute reporting


How to get a sufficiently detailed image into the Component Options box?
#2

@denisroy

Sigh. This is getting WAY more involved that I’d hoped. I just don’t have TIME to learn to use the Ruby Console!

My obsessive attention to this detail is already getting in the way of my real project: using this (and one other similar component I’ve yet to create) to create a dynamic component that reflects a product which, I think, is on the verge of becoming popular enough that I can sell the manufacturer on the rights to the component, thus putting their brand on a component of great use to SketchUp newbies who are creating a particular type of model. (Yes, I know this is really vague, but I’m not yet ready to disclose details for fear of someone else with more experience than me beating me to extracting fees from this manufacturer!)

I AM going to try one thing fairly quickly: I’m going to create a spreadsheet with two columns (option and value), populate it with a few pairs, then see what happens if I copy the list to my clipboard, then paste while inside “Add option” – Finger’s crossed!


#3

Why not have 3 separate options for A, B, C.

A: 1/2, 3/4, 1, etc
B: 1/2, 5/8, 1, etc
C: 1/2, 3/16, 1/4, etc
Instead of:
Option: 1/2x1/2x1/8, 5/8x5/8x1/8, etc

It’ll be cleaner and less combinations


#4

@quantj,

Simple: I’m trying to create a component that is restricted to standard sizes available from any number of suppliers.

And now, having failed in my spreadsheet copy/paste experiment, I’m going to give up (for now) publishing this as it’s own component, go ahead and use A, B, C as you suggest so I can use it in my REAL project. I just won’t (for now) be able to put up a nice “Stock Size Angle Stock” component. As I use it myself, I’l just use standard sizes without being restricted to standard sizes.


#5

The real answer is that the spreadsheet table needs to be exported as a CSV (comma separated values) file.

Then a Ruby script would process the CSV file adding the options to the model level “dynamic_attributes” dictionary. I could see it being quite straight-forward if the csv filename was the attribute name.
ie: “Standard Size (Inches).csv”

I have lost count of the number of times @TIG has shown code samples for importing CSV file data. You can do a search on his posts here in the Ruby forum or over at SketchUcation.


#6

Thanks @DanRathbun for the precision.

The link to the attribute reporting tutorial was intended for him to get acquainted with Ruby in conjunction with DC rather than being a solution in and of itself.

Searching TIG’s post here with CSV as keywords yields 3 unrelated results. There are probably a bunch of info on SketchUcation but I’ll leave @sjdorst skim for it if he eventualy decides to take that route.

Thanks again. it’s always easier to search when one knows what to search for! :slight_smile: