• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Get points from a Sketchup object

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 3 Posters 1.6k 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.
  • V Offline
    vhiguita
    last edited by 10 Aug 2012, 02:50

    Is there a method in ruby or a way to get all the 3D points (x,y,z) from a sketchup Object?

    Thanks in advance.

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 10 Aug 2012, 09:07

      Moved this to the Developers' Forum where it will get better attention...

      https://developers.google.com/sketchup/docs/ourdoc/boundingbox
      returns info like center and the eight corners of the object's bounds.

      https://developers.google.com/sketchup/docs/ourdoc/transformation
      returns info like 'origin', rotation etc.

      If you want the 'vertices' [end-points] of all edges in an object you iterate the edges, collect an array of the edge.vertices, .flatten! it, .uniq! it and then iterate the vertices, collecting all of the vertex.position point3d info which is xyz - however if it's an instance or group you need to apply its transformation to these to get them in 'model-coordinates' if needed...

      TIG

      1 Reply Last reply Reply Quote 0
      • A Offline
        Aerilius
        last edited by 17 Aug 2012, 21:21

        An object of what you mean is a Sketchup Drawingelement.

        If the Drawingelement is a Face, Edge, ArcCurve or Curve, it will have a method to get all vertices, and for each vertex you can get the position (which is what you want):
        positions = face.vertices.map{|v| v.position}

        If the Drawingelement is a Group, ComponentInstance of Image, it is "a model" in the model any you have to loop over the contained entities:
        group.parent.entities.find_all{|e| e.respond_to?(:vertices) }. map{|e| e.vertices.map{|v| v.position} }.flatten
        or with
        component.definition.entities

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

        Advertisement