[Plugin] Export Vertices to CSV
-
@tig said:
What format does your Topo software need.
The format:
137.0 122.0 -2.0
Looks to have the standard '.' as the decimal-point NOT ',' as you might use in Spain... and is separated by a space OR a TAB ? Using a ',' wouldn't work with that in the numbers too !
Also what units are expected etc?
The numbers after the decimal point truncate to .0 if there are no more ?
There are various ways of exporting things like this around the forums.
For example, do you really want to export 'vertices' ?It's separated by a ","; and the '.' is the decimal separator. Anyway the software used to read it it's not a problem. I mean, I have copied the text numbers from a text editor. Anyway, if you want, you have here from notepad:
142.0,120.0,-0.0
142.0,122.0,-0.0
143.0,120.0,-0.0
140.0,120.0,-1.0
140.0,122.0,-0.0So the text editor is not a problem. Sketchup generated that file as you read it.
I would like something like 142.24, 129.89, -0.025 (at least 2 decimals, or cm). It's for a topographical map I made by photogrametry. I am experimenting, to be honest, trying to find if this way of making maps is useful for my work.
I have to leave to go to lunch in 20 minutes, see you this evening. (The spanish lunch, a lot of food. But no siesta.)
-
If I load the original .rb from the first post of this thread and then type
Exportvertices2csv.new
etc; then with the Model Info > Units set as 'meters', with 0.000 and no 'm' suffix etc, it works fine on the selected geometry's vertices.
Vertices with exact 'm' values report as whole numbers
1,2,3
but when with 'mm' parts they appear as
1.234,5.67,8.9
etc...
So I don't see how you are getting these results
With the same Model Units setting as above, as a test preselect a simple face [but one that is NOT 'flat' in 3d] and copy/paste this code-snippet into the Ruby Console + <enter> and report the output.Sketchup.active_model.selection[0].vertices.each{|v|puts v.position.x.to_s.gsub(/^~ /,'').to_f.to_s+','+v.position.y.to_s.gsub(/^~ /,'').to_f.to_s+','+v.position.z.to_s.gsub(/^~ /,'').to_f.to_s}
Are the values as you might measure 'on screen' ???
-
Before doing what you told me (copy and paste your code), and after reading you, I selected mm instead of m.
These were the results for the first 5 lines:
142416.0 120527.0 -532.0
142416.0 122200.0 -13.0
143444.0 120527.0 -13.0
140002.0 120527.0 -1720.0
140002.0 122941.0 -965.0After that, I selected again "m" (meters), and these were the results:
142.0 120.0 -0.0
142.0 122.0 -0.0
143.0 120.0 -0.0
140.0 120.0 -1.0
140.0 122.0 -0.0A workaround would be to obtain the results in millimetres, and divide them by 1000, so I can obtain 142.416 and so on.
Now I am going to do what you told me.
With "meters" as the selected unit, I choose a face (a triangle):
@unknownuser said:
Sketchup.active_model.selection[0].vertices.each{|v|puts v.position.x.to_s.gsub(/^~ /,'').to_f.to_s+','p+v.position.y.to_s.gsub(/^~ /,'').to_f.to_s+','+v.position.z.to_s.gsub(/^~ /,'').to_f.to_s}
Error: #<SyntaxError: (eval):155: compile error
(eval):155: syntax error, unexpected tIDENTIFIER, expecting '}'
....gsub(/^~ /,'').to_f.to_s+','p+v.position.y.to_s.gsub(/^~ /,...
^>
(eval):155With "millimetres" as the selected unit:
@unknownuser said:
Sketchup.active_model.selection[0].vertices.each{|v|puts v.position.x.to_s.gsub(/^~ /,'').to_f.to_s+','p+v.position.y.to_s.gsub(/^~ /,'').to_f.to_s+','+v.position.z.to_s.gsub(/^~ /,'').to_f.to_s}
Error: #<SyntaxError: (eval):155: compile error
(eval):155: syntax error, unexpected tIDENTIFIER, expecting '}'
....gsub(/^~ /,'').to_f.to_s+','p+v.position.y.to_s.gsub(/^~ /,...
^>
(eval):155Hope it helps.
-
Out of curiosity, to what is 'Precision' set when you are using metres as the units?
-
The precision for 'meters' MUST be 0.000 ! to get up to 3dps reported...
Sorry but there was a typo in the line of code.
Retry copying it again from the earlier post.
It should return a list of values:Please also try this line too
Sketchup.active_model.selection[0].vertices.each{|v|puts v.position.x.to_s+','+v.position.y.to_s+','+v.position.z.to_s}
It might be down to you using a ',' as a decimal-point rather than a '.' ?
-
@dave r said:
Out of curiosity, to what is 'Precision' set when you are using metres as the units?
@unknownuser said:
The precision for 'meters' MUST be 0.000 ! to get up to 3dps reported...
As a curiosity, some of Mars Curiosity instruments were tested in the place I am trying to make the topographic map (and thanks for teaching me the meaning of the expression "Out of curiosity")
I attach you a capture with the settings I've been using. In spanish, but you'll understand it. And yes, I've been using a precision of 0,000 , as you can see in the attached image.
Tig, with the new code, the results are:
@unknownuser said:
Exportvertices2csv.new
#Exportvertices2csv:0x1a8911dc
Sketchup.active_model.selection[0].vertices.each{|v|puts v.position.x.to_s+','+v.position.y.to_s+','+v.position.z.to_s}
-141,225,-82,242,-19,325
-142,207,-82,242,-20,532
[#Sketchup::Vertex:0x1a4423d8, #Sketchup::Vertex:0x1a42d8e8]I think you are right, Tig. Now I am trying to find way to change it in my preferences (although you know that the use of "," and "." varies a lot between countries). It's always been a problem, for example I use Libreoffice in Spanish and the use of the numeric punctuation in Libreoffice Calc is problematic, Mexicans use a system, here in Spain we use another...
-
I see the issue now.
It is related to ',' versus '.'
I'll post an update... -
Here's v1.2 http://sketchucation.com/forums/viewtopic.php?p=298614#p298614
A ',' can now be used as a decimal-point, as well as a '.'... AND keep the d.p. values set in Model Units...This fixes pichuneke's problem
-
@tig said:
Here's v1.2 http://sketchucation.com/forums/viewtopic.php?p=298614#p298614
A ',' can now be used as a decimal-point, as well as a '.'... AND keep the d.p. values set in Model Units...This fixes pichuneke's problem
Thanks a lot, I'll send you a private message with a image of the results of my experiments
-
I'd be grateful for the feedback.
I'm sure this'll fix your locale issue... but I can't test it directly ! -
It works!
142.416,120.528,-0.533
142.416,122.201,-0.013
143.444,120.528,-0.013
140.002,120.528,-1.721
140.002,122.941,-0.965I'll make the map later
-
Forgive me, but I am new to Sketchup. I have Sketchup Pro 8.0 and I VERY VERY MUCH am excited about your plug-in that permits export of CSV files from terrains. In fact, it is amazingly exactly what I have been looking for.
Alas, probably because I am a newbie I am having no luck getting it to work.
I installed the .rb file in the plug-ins as stated and I pasted "Exportvertices2csv.new" in the Ruby Console.
I get this result:
Exportvertices2csv.new
Error: #<NoMethodError: undefined methoduniq!' for nil:NilClass> C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/exportvertices2csv.rb:30 (eval):0:in
new'
(eval):0Can somebody help me understand what I'm doing wrong? Could it be because I am using the Eval version? Or, am I just dumb as a rock and missing something obvious.
16Feb2014: Figured it out and am MOST appreciative of this very useful tool.
-
I absolutely LOVE this tool and want to thank you, TIG, for your generosity.
One thing, though. It seems that when I bring the resulting CSV file into another application to generate a terrain, I get some artifacts that seem to be almost linear whereby some of the points are too high and some too low. See the images below. The top is the terrain inside Sketchup and the bottom example is from SiteTOPO showing the sort of linear artifact lines that are showing up in my generated terrains:
I've imported files into several different applications (ARAS 360HD, AutoCAD MAP3D, SiteTOPO) and all show the same artifacts so I assume it is somehow occurring as the grid is generated in Sketchup. It is a pain to clean up the artifacts so I'm hoping somebody can help solve this for me.
-
I assume if you view the original mesh SKP in Monochrome mode with View > Hidden Geometry ON, you don't see these 'artifacts' ???
Can you post [or PM] the original mesh SKP and resultant mesh after export.
I suspect it's something to do with perhaps 'vertical' or inverted faces ?
Once we see the SKP we can hopefully find out... -
@tig said:
I assume if you view the original mesh SKP in Monochrome mode with View > Hidden Geometry ON, you don't see these 'artifacts' ???
Can you post [or PM] the original mesh SKP and resultant mesh after export.
I suspect it's something to do with perhaps 'vertical' or inverted faces ?
Once we see the SKP we can hopefully find out...Thank you so much TIG. This happens on all the terrains I've generated so far. I'm attaching the SKETCHUP file and also the CSV file that is generated from your script. Here's what the terrain looks like when I bring the CSV file into my terrain generator:
As you can see, there are pits and spikes that shouldn't be there.
I really appreciate your help as this would be an incredibly useful tool for me to have.
Many many thanks for your generosity. I sent you a donation and will encourage my compadres to do so as well.
-
I'll try and look at it on Wednesday...
At first sight I can't see why it should do that...It's a very simple script so it ought to work and/or be fixable
-
Here's v1.3 http://sketchucation.com/forums/viewtopic.php?p=298614#p298614
Get it from the PluginStore download link, or AutoInstall it from within SketchUp itself...The recently reported issues of 'artifacts' appearing in exported meshes was caused by having the Model Units set to 'Fractional' [already advised against!] but it is is now trapped - the Units LengthFormat is temporarily reset to 'Decimal' whilst it is exporting, and it's reset afterwards as needed.
It also now in a 'TIG' module.
It has a new easy to use File menu itemTIG.exportvertices2csv
to run it.
Or you can still use the clunky Ruby Console 'command-line' [note that you now must typeTIG.exportvertices2csv
] -
Beautiful work. I tip my hat to you for making this great tool. This provides me with a very easy way to bring 3D Google Earth terrains into an external application. Bravo TIG!
-
Hi TIG,
The export2CSV does not extract the points in the proper manner. You may export a circle and draw a Scatter Graph in MS Excel. The lines appear out of order.
Would appreciate if there is any improvement
-
@isher said:
Hi TIG,
The export2CSV does not extract the points in the proper manner. You may export a circle and draw a Scatter Graph in MS Excel. The lines appear out of order.
Would appreciate if there is any improvement
It just exports the vertices.
It does not order them.
A 'Delauney' algorithm is probably needed to arrange them...
Advertisement