<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Import csv data using ruby]]></title><description><![CDATA[<p dir="auto">Howdy folks, I'm hoping someone can help me out. I want to do three things, can anyone cleverer than me tell me whether this is possible?</p>
<p dir="auto">1: Using the ruby window, access xyz data in a csv file</p>
<p dir="auto">2: define each xyz co-ordinate as a point</p>
<p dir="auto">3: draw a face between the points.</p>
<p dir="auto">I can define points and draw the face no problem. But when I try to access the csv file I just get error messages. Is there somewhere I need to put the csv file? Even better, does anyone know a plugin that will do this for me?</p>
<p dir="auto">Regards,</p>
<p dir="auto">Cathal</p>
]]></description><link>https://community.sketchucation.com/topic/132724/import-csv-data-using-ruby</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 16:14:32 GMT</lastBuildDate><atom:link href="https://community.sketchucation.com/topic/132724.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Jan 2012 11:42:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Import csv data using ruby on Wed, 18 Jan 2012 13:03:29 GMT]]></title><description><![CDATA[<p dir="auto">That's fantastic, thanks so much.</p>
]]></description><link>https://community.sketchucation.com/post/1304157</link><guid isPermaLink="true">https://community.sketchucation.com/post/1304157</guid><dc:creator><![CDATA[installtechireland]]></dc:creator><pubDate>Wed, 18 Jan 2012 13:03:29 GMT</pubDate></item><item><title><![CDATA[Reply to Import csv data using ruby on Wed, 18 Jan 2012 12:40:28 GMT]]></title><description><![CDATA[<p dir="auto">Assuming your CSV file looks like this<br />
<code> 1,2,3 1,3,3 0,2,3</code><br />
etc<br />
Then you need to specify the path to the CSV file<br />
This line opens a browser and if you choose a file it returns the path - you ought to check for validity of the file etc...<br />
<code> csv=UI.openpanel("Choose CSV File...")</code><br />
Then you can read the file into an array thus:<br />
<code> lines=IO.readlines(csv)</code><br />
Then process each line in turn - chomping the '\n' off the end and skipping blanks etc<br />
` lines.each{|line|<br />
line.chomp!<br />
next if line.empty?</p>
<h3>do your stuff here on 'line'</h3>
<p dir="auto">}#end of each<code>'Your stuff' is to split each line into its X,Y,Z values. It's currently a string</code> "1,2,3"<code>so use split</code> xyz=line.split(",")<code>which gives you</code> ["1", "2", "3"]<code>So</code> x=xyz.x.to_f<br />
y=xyz.y.to_f<br />
z=xyz.z.to_f<code>Where the three values are made into 'float' numbers for x/y/z. Now use those to say add a cpoint...</code> Sketchup.active_model.active_entities.add_cpoint([x, y, z])`<br />
Do this inside the 'each' {} block and each point gets a cpoint added...<br />
<img src="https://community.sketchucation.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f913.png?v=e3ff0b7518f" class="not-responsive emoji emoji-android emoji--nerd_face" style="height:23px;width:auto;vertical-align:middle" title=":nerd_face:" alt="🤓" /></p>
]]></description><link>https://community.sketchucation.com/post/1304147</link><guid isPermaLink="true">https://community.sketchucation.com/post/1304147</guid><dc:creator><![CDATA[TIG]]></dc:creator><pubDate>Wed, 18 Jan 2012 12:40:28 GMT</pubDate></item><item><title><![CDATA[Reply to Import csv data using ruby on Wed, 18 Jan 2012 12:22:26 GMT]]></title><description><![CDATA[<p dir="auto">Hi, thanks for replying so fast.</p>
<p dir="auto">I'll post an error code as soon as I can find it again: I'm on a different machine right now.</p>
<p dir="auto">Regarding making faces, I was simply using:</p>
<p dir="auto">pt1 = [0,0,0]<br />
pt2 = [0,1,0]<br />
pt3 = [1,1,0]<br />
pt4 = [1,0,0]</p>
<p dir="auto">face = Sketchup.active_model.entities. add_face pt1, pt2, pt3, pt4</p>
<p dir="auto">I can continue to do that with the rest of the points. But how do I tell it that the first line of the csv file defines "pt1", the second line defines "pt2", etc?</p>
<p dir="auto">Apologies if this is very basic stuff, I only started with Ruby last week <img src="https://community.sketchucation.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=e3ff0b7518f" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":disappointed:" alt="😞" /></p>
<p dir="auto">Cathal</p>
]]></description><link>https://community.sketchucation.com/post/1304143</link><guid isPermaLink="true">https://community.sketchucation.com/post/1304143</guid><dc:creator><![CDATA[installtechireland]]></dc:creator><pubDate>Wed, 18 Jan 2012 12:22:26 GMT</pubDate></item><item><title><![CDATA[Reply to Import csv data using ruby on Wed, 18 Jan 2012 12:08:23 GMT]]></title><description><![CDATA[<p dir="auto">There are already several points cloud tools in the Plugins Index.<br />
It's easy to get the file to be read in as an array of values.<br />
Read their code.<br />
There are tools to add cpoints at each X,Y,Z CSV point [there are then tools to make a mesh from the cpoints], others make the mesh faces directly from the CSV X,Y,Z values directly...<br />
One issue you'll find when making faces is that you'll need a delauney tool to work out the triangulation of many points forming the mesh...<br />
UNLESS you structure you CSV file's points in a specific way, so you know that every three points [lines of X,Y,Z] in the file define a triangular facet...<br />
If your points form say square faces you need something to tell your tool when one face is done and another starts, also all points must be coplanar - this is automatic with triangular faces, because any three points are by definition coplanar and will form a face [provided that that are not all coincident or colinear!]<br />
Delauney will fail on vertical faces as it has no way of knowing which facet is which...</p>
]]></description><link>https://community.sketchucation.com/post/1304142</link><guid isPermaLink="true">https://community.sketchucation.com/post/1304142</guid><dc:creator><![CDATA[TIG]]></dc:creator><pubDate>Wed, 18 Jan 2012 12:08:23 GMT</pubDate></item><item><title><![CDATA[Reply to Import csv data using ruby on Wed, 18 Jan 2012 11:59:56 GMT]]></title><description><![CDATA[<p dir="auto">If you could post the error message it would help. That provides valuable information.</p>
]]></description><link>https://community.sketchucation.com/post/1304141</link><guid isPermaLink="true">https://community.sketchucation.com/post/1304141</guid><dc:creator><![CDATA[thomthom]]></dc:creator><pubDate>Wed, 18 Jan 2012 11:59:56 GMT</pubDate></item></channel></rss>