• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Exporting vertices of every edge to csv

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 3.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    CoreMaster110
    last edited by 7 May 2018, 21:33

    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

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdmitch
      last edited by 8 May 2018, 15:01

      @coremaster110 said:

      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

      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.

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • C Offline
        CoreMaster110
        last edited by 9 May 2018, 07:56

        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

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement