exporting vertices of every edge to csv

exporting vertices of every edge to csv

Postby CoreMaster110 » Mon May 07, 2018 10:33 pm

Hi!

I have no real experience with coding and I just started familiarizing myself how Ruby works as I need very specialized but simple plugin.
Basically I need to export start and end vertice for every edge. Even for the ones that are connected to each other, which means that shared vertices get exported twice, once for each edge.

For example: (x and Z only)
Edge 1 = ( 0.0, 0.0 ); ( 5.0, 6.0 )
Edge 2 = ( 5.0, 6.0 ); ( 12.0, 8.0 )

And to make it as easy as possible I downloaded TIG's "Export Vertices to CSV" plugin. I studied it to understand how it works and now plan to hopefully modify it according to my needs. I also downloaded TIG's "Coords-Tag from Datum" plugin and also plan to study it to gather more knowledge.

So here is what I'd like to ask before I waste a lot of time:
Is this even possible? If yes, then how difficult would that be?

Also I wouldn't mind any tips.

Regards,
Karl
0
User avatar
CoreMaster110 
 

Re: exporting vertices of every edge to csv

Postby sdmitch » Tue May 08, 2018 4:01 pm

CoreMaster110 wrote:Is this even possible? If yes, then how difficult would that be?

Also I wouldn't mind any tips.

Regards,
Karl


Yes and not very.

the basics would be
Code: Select all
mod = Sketchup.active_model
ent = mod.active_entities
SKETCHUP_CONSOLE.clear; cnt=0
ent.grep(Sketchup::Edge).each{|e|
 cnt += 1;
 sx,sy,sz = e.start.position.to_a;
 ex,ey,ez = e.end.position.to_a;
 printf("Edge %d = (%.1f,%.1f); (%.1f,%.1f)\n",cnt,sx,sz,ex,ez)
}

which would output to the Ruby Console.
0
Nothing is worthless, it can always be used as a bad example.

http://sdmitch.blogspot.com/
User avatar
sdmitch 
PluginStore Author
PluginStore Author
 

Re: exporting vertices of every edge to csv

Postby CoreMaster110 » Wed May 09, 2018 8:56 am

Oh wow, thank you! It works great.

It's actually pretty simple and straight forwards. I did hope that start and end positions allow something like this to be done.

Regards,
Karl
0
User avatar
CoreMaster110 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: Aifort, MarkusP and 8 guests

Visit our sponsors: