Importing geometry from Excel or text files

I want to draw shapes which are basically sine waves imposed on the inside and outside of circles. I have generated the coordinates in Excel and would like to import them into Make (preferably as lines). I have looked on the net for help and it seems that it was possible to do this in earlier versions by creating text files but this may not be possible in v2016. Even dxf files don’t appear to be supported in Make so I’m not sure Autocad can help me. I know in Pro all sorts of amazing shapes can be produced now but I am not using it professionally so didn’t want to buy it at this stage. It would appear that the developers at Sketchup are moving away from basic support for other files to concentrate on exotica like Google Earth, etc but there are a lot of people who would still find a link to Excel data advantageous. I know this is old school but can someone tell me if this is still possible? Or is Pro the only way to go?

SketchUp has a Ruby API which can be used in both Make and Pro to import, export or generate point sets, with or without ‘edges’ or ‘faces’…

adding an image of what you are hoping for and an example point set, would help focus replies…

john

1 Like

Thanks John. Can you tell me how I access it/load it please?

One of the shapes I want to draw is like a cam, as found operating the valve gear in engines. I can generate coordinates in 2 ways, either by angles from 0 to 360 around the circumference, or x and y coordinates from the origin. Hope that makes it clearer but if not I’ll try to include an image and short table of data.

to use the builtin ‘Ruby Console’ yourself have a look at the guide…

SU API link

but the API also means there is possibly an extension to do what you want by clicking a menu item and inputting some values…

for an automotive type cam lobe, I would just draw it directly in SU, but without an image and points data it’s impossible to know if it would suffice…

john

The Ruby API is always loaded when SketchUp starts (unless you specifically use an obscure command line parameter to switch off Ruby.)

There are likely already examples and discussions of import TXT and CSV data using Ruby. Check the topics in the Ruby API category.


(Moving this post to Developers > Ruby API category.)

Please see the Ruby Learning Resources wiki topic for links to help you learn Ruby.

Hi Notpicasso, hi folks.

There is a plugin available on the Extension Warehouse called “Point Gadget 2” (for SU 2016) that allows the importation of civ files in SU.

Set your Excel file so that the coordinates are in X Y Z order. Set Z to 0 for all points to get 2D points on the ground plane.

Just ideas.

Jean

3 Likes

I have an example of an extension (that was translated from Python to Ruby,) that draws a profile of a hypocycloid cam. It is in the Extension Warehouse:

http://extensions.sketchup.com/en/content/hypocycloidcam

I suppose it could also be modified to draw other types of cams.

Here are a couple of posts (in this category,) regarding the reading of CSV data files into Ruby:

[url]http://forums.sketchup.com/t/help-planogramming-show-stand/25351/4[/url]

[url]http://forums.sketchup.com/t/create-materials-paint-colours-palette-from-list-of-names-and-rgb-values/21475/4[/url]

I created a simple plugin that will take x,y,z values from a comma-separated text file. For example:

10,2,0
10,3,0
9,3.4,0

The plugin is available here … if you need assistance getting it to work, let me know. Note that the plugin requires that the text file be named with a “.txt” extension.

Coming at your problem in a different direction …

If you have equations you want to use, you might take a look at the U-VPolyGen plugin (available here). For example, a cam plotted in [x,y,z] coordinates with a nominal radius of 10" and a sinusoidal superposition of +/- 0.5" at 8x frequency can be generated by the parametric equations (in terms of u where 0 <= u <= 2π):

x = (10 + sin(8u)) * cos(u)
y = (10 + sin(8u)) * sin(u)
z = 0

The plugin uses Ruby syntax for the input equations, so these need to be modified to read:

x = (10.0 + Math.sin(8.0 * u)) * Math.cos(u)
y = (10.0 + Math.sin(8.0 * u)) * Math.sin(u)
z = 0

While the plugin is designed to generate 2D surfaces in 3D, it can be short-circuited to create 1D curves in 3D by setting the second parametric variable (v) to the values shown:

This will create the cam shape shown:

3 Likes

Author a simple CSV format text file of the coordinates.

This plugin will import the CSV text file and create a guide point at each coordinate.
Optionally, it will triangulate the guide points, drawing edges and make faces for the triangles.

Be aware it was designed to triangulate generally horizontal terrain point clouds.
YMMV when attempting to triangulate vertical sides of a cam.
Still, one can always rotate the points cloud and do one side at a time or hand stitch with the Line tool.
Or perhaps import just the planar profile coordinates and develop the geometry from there.

Cloud v8.0bxx — SketchUp plugin by Didier Bur (updated by TIG)



FYI
SU development certainly doesn’t “concentrate on exotica like Google Earth
The SU Make/Pro KMZ exporter is more of a legacy feature than anything else.

Creating building models in SU to populate Google Earth is the reason Google acquired SketchUp.
As Google developed automated processes to populate GE, they began to lose interest in SU.

Trimble acquired SU in early 2012.
Thanks to Trimble’s commitment to invest in SU’s growth, SU has been able to innovate and develop new features better than ever before.

Google no longer accepts user contributed SU models for inclusion in GE’s Building Layer.
Yet one can still export KMZ files from SU and import the model into GE running on their computer.



FYI
The DXF importer was removed from SU free version many years ago; SketchUp 7.1 released 9/22/2009



FYI
To my knowledge (SU 6 thru SU 2016) CSV import has never been a native feature.
Didier Bur’s venerable Cloud plugin dates all the way back to SU 5

2 Likes

At the risk of repeating myself …

For example, using the following text file:

test.txt (2.6 KB)

Hi Jim,

This is a bit of a blast from the past, in fact from about 15 months ago. At the time I was struggling to draw some awkward profiles in Sketchup and you very kindly forwarded a plugin to help me import them from Excel.

I apologise for the delay in getting back to you but out of the blue I received notification that my neighbour wanted to build a large extension beside my house which would take all the light from a living room in my property. I have had to spend all my free time since then fighting the action, even resorting to legal action in the end, but at last it seems to be sorted, and I am picking up from where I left off on the sketchup project.

I don’t know if you have a way of recording when people access your software but if you have you may have noticed that I did yesterday. Anyway I can tell you it worked a treat and my whole reason for writing is to say how grateful I am. It’s really good of you to help people in this way and I do appreciate it. Sorry if you thought I was just a rude ungrateful ■■■■■■■ but believe me the other business got worse before it got better.

Incidentally there was a tiny thing in the program which I don’t know whether you are interested in or not. It assumed that my dimensions were in inches whereas in fact they were in millimetres. It was very easy for me to solve (I just divided everything by 25.4) and I’m only mentioning it in case you are interested in making the routine more universal, as it were. I certainly found it very useful and I am sure that other people will too. Really pleased that there are clever guys like you around.

Anyway thanks again for your help,

Stuart Jarvis

Hi Jim,

Spending hours looking for a simple extension to import excel spreadsheet or txt or csv 3D object dimensions into sketchup.

The file is just woodworking project 3D components: Height, Width and Depth

55, 140, 340
etc

Any interest is modifying the jimhami42_import_lines.rbz script to do this?

Thanks heaps and all my best

I’m not quite sure what you want, but you can try this plugin:

https://sites.google.com/site/spirixcode/code/jimhami42_import_boxes.rbz

It takes “Height, Width, Depth” as row input from a text file and uses the parameters to create “boxes” in separate groups.

Absolute champion!
Thanks so much for the quick reply.
Really appreciate the effort.

The post was a last ditch effort as I was ready to throw in the towel late last night.
New energy this morning and a new direction.

Thanks heaps and all my best


Not working in SU2018 as far as I can tell.

Have unzipped and looking at the code in textedit on mac
Really didn’t want to get into the code as I finally gave up coding after 35 years in IT.
Han’t missed it as I have so much more time doing other things.

But it’s cold outside today. So will have a go while I wait for the temp to rise.

1 Like

Now wondering if Sketchup has an interactive development environment for Ruby …

Can you be more specific? If you launch the Ruby console (Window >> Ruby Console) before running it, you will see any errors. As I recall, the file open for Macs was somewhat problematic.

LOL! Luckily I caught myself with 30+ windows open looking for info.
Had a break and returned and decided NOT to pursue scripting myself.
I’ve just copied and pasted the dimensions into sketchup one component at a time.
There were only about 30 or so.

The file open for the original ImportLines.rbz worked ok.

The ImportBoxes did’t do anything as far as I could tell.

I’ll try the Ruby Console now …

Yep working now.
Wonder if it was a reboot about 15 minutes ago or adding the Ruby Console+ Extension?
Or just another noob fumbling about.

Thanks heaps.

Can’t wait to use it on the next project.

All my best.

Absolute Champion!

Note to self:

vbLf = Chr$(10)

'Developing in VB
’ - Each end of line for TextEdit .txt is just a ascii character 10 - Linefeed
’ - NOT a 13 - carriage return and not Carrige Return Line Feed

25,51,76
305,267,19
660,267,19
660,260,19
41,260,19
127,521,19
102,102,19
406,610,19
470,267,19
406,70,19
406,70,19
76,229,19
432,1607,19
444,635,19
219,19,19
324,19,19
181,19,19
219,959,19
457,25,19