Importing geometry from Excel or text files

import
pointdata
txt
csv
xls

#1

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?


#2

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


#3

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.


#4

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


#5

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.


#6

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 cvs 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


#7

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.


#8

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

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

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


#9

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:


#10

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


#11

At the risk of repeating myself …

For example, using the following text file:

test.txt (2.6 KB)


#12

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