Creating a box with attribute from an excel file

Hello,
I have been using the build box extension from JimHami42 that creates a box from a csv comma separated file. I would like to expand on it and add an attribute automatically (the name) in entity info. the text would come in from three different values sorted previously in an excel file. Would anybody know where to begin with this?

Thanks for your help.

What version of SketchUp are you using? Your profile indicates SketchUp Free (Web) 2015 which doesn’t exist. The correct information will help us help you.

Thanks for reaching out, I am actually using Sketchup Pro 2015.

How about fixing your profile?

Maybe you could get what you need by making a Dynamic Component?

You might also ping @jimhami42 and see if he has any thoughts for you.

Thanks for that DaveR, I fixed my profile. I will look into the Dynamic components to see if I can find a solution

1 Like

No the DC “Name” attribute will not be reflected in the Component “Name” property that you see displayed in the Entity Info inspector.

You will need to solve this using the SketchUp Ruby API.
To use it, you should first learn the basics of Ruby (as SketchUp’s API only extends the Ruby language.)

So, please edit this topic title, and reassign the topic to the Ruby API subcategory.

I created a bunch of different plugins to create things from data files. If you could be more specific, or provide the plugin, I can maybe help you.

1 Like

Hello Jim,
Thank you for replying to this thread, I have been using your plugin jimhami42_import_boxes.rbz extensively to import shapes from an excel list. In an effort to streamline my process I would like to figure out how to add some attributes to the box creation if possible.

Here’s a quick fix to see if this is what you need. The name needs to be the first element on each line of the list and may not contain any spaces.

Box_A,12,5,3
Box_B,6,2,4
Box_C,8,4,2

image

The modified plugin is here: jimhami42_import_boxes_alex.rbz (607 Bytes)

Let me know if this works for you.

Jim, this works perfectly, thank you for taking the time to do this.
Would you be able to send me a private message as I would like to develop the extension further?

Again Thank you,

Alex

Dear Jim, maybe you have a solution on fast moving these solids out of bundle?

Can you provide a sample of the what you need? Do these need to be spread out? In an array? I’m not clear on what you’e trying to accomplish … a picture might help.

Hi, sorry to jump into this after a year. I see that this topic suddenly ended and was curious about the last question.
I’m just trying the extension and had basically the same question. How to create a csv where the different blocks are separated in sketchup? Now they appear all on top of each other.

One other question: for example box,20,10,10
this will create a height of 20 , width of 10 and length of 10. However my sketchup is set in meters and for some reason it converts the data also to meters where I basically want to have a box of 20m x 10m x 10m. My box appears as H=0.51m W=0.25m L=0.25m.
Why is this happening?

SketchUp uses inches internally.

If the extension code reads the input and runs it through the String#to_l, then if your CSV fields include the unit, ie "20m" instead of "20" (defaulting to inches), then you should get properly sized objects.

The CSV file would also need to supply X, Y and Z fields for the origin coordinates of the box. Then the code would need to also need to read those values and use them to position the box (either whilst it draws or as a translational transform to apply to the box group afterward.)

1 Like

Thank you Dan for your quick reply always.
I have added the units as you mentioned, but that does not make any difference when importing the csv file.
example: my csv file read just 1 line
BOX1,10m,5m,4m
I still get a box of 0.25m x 0.13m x 0.10m
Somehow this did not do the trick and stays in inches.

Could you add a csv file with 2 boxes separated in sketchup (incl x,y,z fields)?

I’ve modified the plugin to assume the inputs are already in meters. No need to add the “m” on each value in the input file. A test file like:

Box_A,12,5,3
Box_B,6,2,4
Box_C,8,4,2

will produce something like:

As a note, @DanRathbun outlines the correct way to fix this, but I hard-coded it as inches to meters since I had trouble with getting the String#to_l to work. This plugin will show up as “Import Boxes 2” on the extension menu.
jimhami42_import_boxes_2.rbz (628 Bytes)

1 Like

Thats it, very nice thank you!

1 Like

Hello,
I’m curious if it is possible to modify this code to automatically pull images from a folder to use as the texture of the boxes?

I can create a database of Name, H in., W in., D in., image.jpg

The idea would be to pull from this data and create an array of boxes lined up with some space between them.

Thank you for your help.