[Plugin] Export Vertices to CSV

[Plugin] Export Vertices to CSV

Postby TIG » Wed Jan 05, 2011 12:31 pm

(c) TIG 2011-2014
Type in the Ruby Console.

TIG.exportvertices2csv

or use the File menu item...

TIG.exportvertices2csv

Exports all Vertices is a Selection to a X,Y,Z 'CSV' file.
Edit sep="," if something other than a separating comma is desired e.g. ';'
Make sep="\t" if a TSV file is desired and change ext="csv" to ext="tsv".
It uses the current Model Units/accuracy with the approximate '~ ' and
unit suffix [if any] removed; e.g. change Model Units to 'meters' 3dp to
get exported csv in meters 1.234 - don't use 'fraction' 1' 2 1/2" formats,
always use a 'decimal' format.
BUT the model's LengthFormat will temporarily change to decimal anyway !
Version:
1.0 20110105 First issue.
1.1 20110116 Wrapped in protective class.
1.2 20121123 Decimal-point ',' now allowed as well as '.'
1.3 20140219 Fractional units trapped. Now in Module. File menu item added.

Get the latest version from the PluginStore

Download

1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby Gaieus » Wed Jan 05, 2011 1:30 pm

Thank you, TIG! :thumb:
:sketchstatic:
0
User avatar
Gaieus 
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby takesh h » Wed Jan 05, 2011 2:50 pm

I was wondering why such a plugin doesn't exist... it must be awfully hard to code, I imagined.
Then I opened TIG's latest script - what? a little more than 30 lines can do this?
TIG must be a genius (maybe I didn't have to tell you that). Thanx! :enlight:
0
User avatar
takesh h 
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby Jim » Wed Jan 05, 2011 3:08 pm

I really wish you would namespace this stuff.

What's the difference for the user between typing exportvertices2csv and TIG.exportvertices2csv
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby TIG » Wed Jan 05, 2011 5:32 pm

Jim wrote:I really wish you would namespace this stuff.
What's the difference for the user between typing exportvertices2csv and TIG.exportvertices2csv

To be flippant it's the "TIG." ;)
But seriously though folks... I do use classes etc for much of more recent complex stuff and I know that if it's to run off a menu item then it is even less hassle... This was just a few lines of code that you could almost type into the Ruby Console, it it took more that one line at a time... What is the difference between typing code into the console and having a few lines load from a script as a new base-class method ?

BUT perhaps to turn it around... please explain clearly why TIG.exportvertices2csv would be S_O__M_U_C_H better than exportvertices2csv ? It's highly unlikely that 'exportvertices2csv' will 'clash' with anything else and adding extra Modules/Classes must also surely 'clog things up'... but perhaps just in a different way to adding methods to the base-class itself ? What terrible problems await those who do it my way ??
You know that I am an Architect and NOT a 'programmer' per se: whilst I am sure that there are very 'good reasons' for your suggested approach, I can still see little benefit to me personally to break a habit of a lifetime and actually do things 'properly' :roll:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby Jim » Wed Jan 05, 2011 6:02 pm

The reasons have been thoroughly covered.

viewtopic.php?f=180&t=29560

It takes in practice no extra time or effort to go from "unlikely" to impossible.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby honoluludesktop » Wed Jan 05, 2011 6:22 pm

TIG wrote:.............You know that I am an Architect and NOT a 'programmer' per se: whilst I am sure that there are very 'good reasons' for your suggested approach, I can still see little benefit to me personally to break a habit of a lifetime and actually do things 'properly' :roll:

You could have fooled me. :) Just kidding out of envy, and admiration.
0
User avatar
honoluludesktop 
In Remembrance
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby Jim » Wed Jan 05, 2011 6:23 pm

Here's an article by Rich Morin about the SketchUp environment:

http://cfcl.com/twiki/bin/view/Projects ... Modularity

(Sorry this is getting off-topic. Please move it if you prefer.)
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby TIG » Wed Jan 05, 2011 7:49 pm

Jim wrote:Here's an article by Rich Morin about the SketchUp environment:

http://cfcl.com/twiki/bin/view/Projects ... Modularity

(Sorry this is getting off-topic. Please move it if you prefer.)
I'm fine with it here for now...
As Rich Morin says...
Ruby offers a nice selection of constructs for modularity.
In rough order of granularity, these include: expression, statement, block, method, module, and class.
It's impossible to write Ruby code without the first two constructs; the following one-line script is both an expression and a statement:
puts 'hello, world'
However, the other levels are completely optional; the programmer must decide whether and where they are needed.
Because each added construct adds complexity, it should provide compensating benefits in program clarity. Otherwise, it's simply unnecessary "overhead".
A short script may get by with several statements, a block or two, and no method, module, or class definitions.
As scripts increase in size, other constructs can add modularity, keeping the code base manageable***.
A code base of several hundred lines might well use all of them to good advantage.
***There is a 'can' in there NOT a 'must'...
So... I generally agree with him... However, I see little benefit is 'modularizing' a short snippet on it's first outing: after all I did cobble this code together within a few minutes... I am not writing 'professional code' here.
Rich Morin comes at this from the opposie direction - he's a programmer writing code that does something for the likes of me - I do something with code for the likes of me - there is a difference... It's like I'm just driving a car down the street - I am not is a Grand Prix or exploring the Arctic like some see to want to do...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV 20110105

Postby thomthom » Wed Jan 05, 2011 8:38 pm

TIG wrote:BUT perhaps to turn it around... please explain clearly why TIG.exportvertices2csv would be S_O__M_U_C_H better than exportvertices2csv ?
[...]
What terrible problems await those who do it my way ??


Method in the global space - and extending methods which is pretty much the same as adding a method in global space - has a chance of clashing.
We have examples of the method box being defined by two plugins in global space. And we have the Array.offset method defined by multiple plugins which has caused issues.

Keeping everything in a namespace is safer - as picking a namespace to id you and keep all your code in there allows you much greater control and security over name-clashes.

Take the Image class for instance, there are several snippets here on this forum that adds .definition and .instance to the Image class. I think some plugins do so. Now, the .transformation addition in all versions is flawed as you know.
I've been trying to get Google to add .definition and .transformation to the Image class - but here is the issue. None of these snippets that extend the Image class checks if the method already exists.
So if Google implements correct .transformation class it'll be overwritten by bugged versions.

It's due to these kind of issues that I stopped working on the SKX project as I saw the potential for causing more clashes. Instead I now use my own library where I don't extend any base classes. It doesn't make my code look as neat as if the base classes had been extended, but it's safe. 100%.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby TIG » Sun Jan 16, 2011 2:48 pm

Update here viewtopic.php?p=298614#p298614
I have wrapped the code in a class to use you now type Exportvertices2csv.new in the Ruby Console or in your own menu item...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby robertWan » Wed Mar 16, 2011 4:18 pm

Hi.
Could you modify :oops: the plugin so that it saves vertices of all (or some) components?
With no need of using Explode.
The name of a component and coordinates of the vertices in SCV file are needed.
It would be perfect if only components with, for example: "plywoodxxx", "drillxxx", in names were saved.
0
User avatar
robertWan 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby TIG » Thu Mar 17, 2011 11:22 pm

It will already save the vertices in any selection - so if you edit a group or component it will save the vertices of things selected in that context.
YOU could simply recast the code so that rather than process selected entities' vertices it goes through the entities in any selected group [or instance-definition] and returns their entities' vertices to a CSV [perhaps transformed by the group/instance's transformation] and named after the group/definition rather than the model... why not try to write it yourself ? :?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby robertWan » Fri Mar 18, 2011 1:10 am

I'll have few hundred components and sub-components.
That is why it can't be hand made.

And I'm not able to write it myself, because I'd have to learn Ruby.

From those coordinates I'm going to make in Exel a file to drilling machine.
Something like a plugin CutList but with coordinates of the holes on a sheet.

Robert
0
User avatar
robertWan 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby TIG » Fri Mar 18, 2011 10:32 am

Robert

Just so I don't go down a blind alley here...

What I think you'd like is that you make a 'selection of things'.
If that selection includes raw geometry you get a 'modelname_verts.csv' file with all of those vertices in [as now].
If its a selection within another context - e.g. a component edit, then the file's name is 'defnname_verts.csv'.
Next, if any items selected are groups or component-instances then we 'mine down' into those and get the raw geometry's vertices in those.
These sets of vertices' locations go into separate files as 'groupname_verts.csv' or 'defnname_verts.csv' as appropriate - the vertices' positions XYZ will be 'transformed' from their actual locations inside their context to the model coordinate system, so that all 'points' are then in the correct relationship if 'overlaid'.
Do you need to process groups/compos inside groups/compos etc ? if you do then those transformations might get painfully convoluted but doable...
This is all quite doable, I just want to ensure I don't do it twice... :geek:

You speak of 'drilling' no centers will be made this way.
You could perhaps have another tool that adds cpoints at the center-points of all arcs/circles and exports a separate CSV list of those these :?:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby charly2008 » Fri Mar 18, 2011 2:45 pm

Hi TIG,

maybe a stupid question of the practical purpose for this plugin. I have no idea at the moment. Maybe you can even give an example please.

Charly
0
He who makes no mistakes, makes nothing
User avatar
charly2008 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby TIG » Fri Mar 18, 2011 2:55 pm

charly2008 wrote:Hi TIG,

maybe a stupid question of the practical purpose for this plugin. I have no idea at the moment. Maybe you can even give an example please.

Charly

One example - if you have a mesh you can export all of its vertices as a CSV and import them into another app as a triangulated mesh.
Another - you can export the CSV list of points into an app that uses them to cut, drill etc...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby charly2008 » Fri Mar 18, 2011 3:08 pm

HI TIG,

thanks for your quick response. Now I understand it.

Charly
0
He who makes no mistakes, makes nothing
User avatar
charly2008 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby robertWan » Fri Mar 18, 2011 10:48 pm

I'm sending .skp file and an example of SCV file.
Drill mark has 3 vertices.
Vertices---line---vertices---line---vertices.
Hinge cylinder and plate aren't needed (many vertices) in SCV file. That is why i would like to be able to choose components. Filter? Precision of vertices' position 0.000. Now they are only integre.

Robert
0
User avatar
robertWan 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby TIG » Sat Mar 19, 2011 2:07 pm

RobertWan wrote:I'm sending .skp file and an example of SCV file.
Drill mark has 3 vertices.
Vertices---line---vertices---line---vertices.
Hinge cylinder and plate aren't needed (many vertices) in SCV file. That is why i would like to be able to choose components. Filter? Precision of vertices' position 0.000. Now they are only integer.
Robert
Capture.PNG

Correct me if I misunderstand you...
First what looks like each 'drill mark' in your SKP seems to made from two lines - so they can then have 3 vertices ?
Does your drilling machine then know the 'vector' of the drilling from some of those and then the start or end of a pair is the point it drills at whilst the second line's vertex gives the depth to drill - how are 'we' to 'know' which vertex is which when it's written into the CSV file ?
Are they vertices always 'drawn' in the same order ?
It might be a lot easier if you have a few standard drill-points to simply use a component instance that has some attributes that we read - when you add the drill-point at a point [used for the drilling] you set a diameter and depth - later when the CSV is compiled we can get the drill-points location and direction from its own transformation in 3D and then read the attributes to get its diameter and depth... The nesting of the drill-point then has to be applied to the location/direction to set it into the model's coordinates - unless of course you really want these applying to a particular panel's transformation - I assume the drilling machine is fixed and the panels passed beneath it - so it's little use knowing if the hole's direction is 'left' when actually it's 'down' on the jig ? :?

To choose particular 'types' of component would be possible but how would you do this ? A list would quickly become unwieldy. In your example - shown above - we have:
Three 'Hinge 35' instances in the model and each
'Hinge 35' contains
'Hinge' which contains
'two drill mark 2mm' which itself contains two instances of
'Drill Mark 2mm'
AND
'two drill mark 5mm' which itself contains two instances of
'Drill Mark 5mm'

So you only wants this starting with 'Drill Mark' AND the side/door reporting in the CSV ?
Or put another way anything starting with 'Hinge' is ignored in the CSV report, BUT things within 'Hinges' are reported if they are 'Drill Marks'....

This nesting of drill marks within the Hinge components makes getting the transformations of each drill-point awkward but not impossible... We have to get the transformation of each instance of the Hinge 35, and the transformation of each Hinge within that instance's definition and the transformation of the 'two drill mark...' instances within that instance's definition and finally the transformation of each 'Drill Mark...' instance within each of those instances :roll:

I have to think about how to iterate all of this...
Can you write a simple step sheet on how you would hope to use this... For example
I open the SKP
I select the assembled cabinet
I run the reporter
I specify what parts are to be reported [or perhaps ignored?]
A CSV file is written... etc

The tolerance of the reported CSV numbers should be the same as you have set in your Model Info > Units, so if you work in mm and only report dims etc to the nearest mm then that's what the CSV has in it too. It could be possible to remember you current setting then temporarily rewrite them to say 3 d.p. [1.234] while the CSV is made and reset back again afterwards... using Sketchup.active_model.options["UnitsOptions"]["LengthPrecision"]
I notice your example SKP has 0.00mm set. So you should get 1.23 in the CSV if the length actually is 1mm it should still format to 1.00 ? If it isn't doing that it can certainly be made to. Read the CSV in Notepad to check - if you open it in Excel it will usually not display trailing zeros or unneeded decimal-points in its cells?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby robertWan » Sat Mar 19, 2011 8:18 pm

TIG wrote:First what looks like each 'drill mark' in your SKP seems to made from two lines - so they can then have 3 vertices ?


Only because that one vertice's components can't be created. At least 3 vertices and 2 lines.
Drill mark.jpg


TIG wrote:Does your drilling machine then know the 'vector' of the drilling from some of those and then the start or end of a pair is the point it drills at whilst the second line's vertex gives the depth to drill - how are 'we' to 'know' which vertex is which when it's written into the CSV file ?
Are they vertices always 'drawn' in the same order ?
It might be a lot easier if you have a few standard drill-points to simply use a component instance that has some attributes that we read - when you add the drill-point at a point [used for the drilling] you set a diameter and depth - later when the CSV is compiled we can get the drill-points location and direction from its own transformation in 3D and then read the attributes to get its diameter and depth...


It will be like that. Only a vertice in the middle will be used. If there are less thank 3 vertices a component can't be created.


TIG wrote:The nesting of the drill-point then has to be applied to the location/direction to set it into the model's coordinates - unless of course you really want these applying to a particular panel's transformation - I assume the drilling machine is fixed and the panels passed beneath it - so it's little use knowing if the hole's direction is 'left' when actually it's 'down' on the jig ? :?

So you only wants this starting with 'Drill Mark' AND the side/door reporting in the CSV ?


Yes. Only those which have in the beginning of a name some phrase. For instance Drill, Door, etc.
Or every that beginns with some character, e.g. "*".
So as in the file there are no unnecessary components, like lamp, floor, ceiling, dishwasher etc.

TIG wrote:Or put another way anything starting with 'Hinge' is ignored in the CSV report, BUT things within 'Hinges' are reported if they are 'Drill Marks'....

This nesting of drill marks within the Hinge components makes getting the transformations of each drill-point awkward but not impossible... We have to get the transformation of each instance of the Hinge 35, and the transformation of each Hinge within that instance's definition and the transformation of the 'two drill mark...' instances within that instance's definition and finally the transformation of each 'Drill Mark...' instance within each of those instances :roll:

I have to think about how to iterate all of this...
Can you write a simple step sheet on how you would hope to use this... For example
I open the SKP
I select the assembled cabinet
I run the reporter
I specify what parts are to be reported [or perhaps ignored?]
A CSV file is written... etc


After thinking it over
Open SKP
run the plugin
only parts beginning with, for example "*" will be reported.
a CSV file is written

TIG wrote:The tolerance of the reported CSV numbers should be the same as you have set in your Model Info > Units, so if you work in mm and only report dims etc to the nearest mm then that's what the CSV has in it too. It could be possible to remember you current setting then temporarily rewrite them to say 3 d.p. [1.234] while the CSV is made and reset back again afterwards... using Sketchup.active_model.options["UnitsOptions"]["LengthPrecision"]
I notice your example SKP has 0.00mm set. So you should get 1.23 in the CSV if the length actually is 1mm it should still format to 1.00 ? If it isn't doing that it can certainly be made to. Read the CSV in Notepad to check - if you open it in Excel it will usually not display trailing zeros or unneeded decimal-points in its cells?

In SU 500,6 but in CSV 500,0 :(
SU.jpg


Box 500,6 x 500,6 x 100,6.txt


Thank you for your help and involvement.

Robert
0
User avatar
robertWan 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby vislaw » Thu Feb 16, 2012 3:06 pm

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 method `uniq!' for nil:NilClass>
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/exportvertices2csv.rb:30
(eval):0:in `new'
(eval):0

Can 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.
0
Last edited by vislaw on Sun Feb 16, 2014 11:37 pm, edited 1 time in total.

vislaw 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby ACP » Fri Nov 23, 2012 4:37 am

Dear Sir:

How do I make Exportvertices2csv.new work on Sketchup Pro 8....?
Is it not supposed to work on version *, or what is the problem with the script.
I am new using Rubi Scripts, but it seems like there is something wrong with the script. here is the message I get on the Rubi Console:

exportvertices2csv
Error: #<NameError: undefined local variable or method `exportvertices2csv' for main:Object>
(eval)

I very much appreciate an answer either here on this forum or by email at:
antonio @ synergyamericas.com

Thank you very much!
Antonio
0

ACP 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby TIG » Fri Nov 23, 2012 11:33 am

@ACP

The way to make it run is - in a saved SKP, select faces/edges etc that you want to export the vertices from, then in the Ruby Console bottom line type [OR copy/paste]:
Exportvertices2csv.new
then press <enter>
It must be written exactly as written above.
It must start with a capital 'E' and end with '.new'
Your example shows you are using a 'lowercase' version, with no terminating '.new' - so only a miracle would make it work in any version of Sketchup !
:roll:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby pichuneke » Fri Nov 23, 2012 1:25 pm

Tig, sorry to say that, but I have the same problem as the rest of some people here.

I am trying to export the points to import them with a software of topography, and I have this csv (sample):

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.0
141.0 122.0 -0.0
138.0 120.0 -2.0
137.0 121.0 -2.0
137.0 122.0 -2.0

As you see, no decimals at all. I have chosen meters, "decimal" and precision 0,000 . No 0,000m extension.

I don't know what to do. I've read this thread and other similar to this: ExportCpointstoCSV (viewtopic.php?f=323&t=40061). I don't like to ask for help and importunate you, but... can you help me?
0
Forgive my spanglish...

pichuneke 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby TIG » Fri Nov 23, 2012 1:56 pm

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' ?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby pichuneke » Fri Nov 23, 2012 2:13 pm

TIG wrote: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.0

So 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.) :D
0
Forgive my spanglish...

pichuneke 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby TIG » Fri Nov 23, 2012 2:34 pm

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.
Code: Select all
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' ???
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby pichuneke » Fri Nov 23, 2012 4:55 pm

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.0

After 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.0

A 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):

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):155


With "millimetres" as the selected unit:

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):155


Hope it helps.
0
Forgive my spanglish...

pichuneke 
 

Re: [Plugin] Export Vertices to CSV v1.1 20110116

Postby Dave R » Fri Nov 23, 2012 5:50 pm

Out of curiosity, to what is 'Precision' set when you are using metres as the units?
0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: atagharehshir, Google Bot, maximt, sketchy22, summerv31, thedaverman and 10 guests

Visit our sponsors: