Search code examples
rubysketchup

What do the coordinates on the Sketchup Ruby API mean?


I'm very new to the Sketchup API and programming in general so sorry if this is a very basic question. I tried clicking on a cuboid I drew and inputted this code to get the coordinates of the bounding box:

model = Sketchup.active_model
model_bb = model.bounds

However, sketchup returns this:

#<Geom::BoundingBox:0x0000005063c360>

What does this mean and how can I turn these into x,y,z coordinates that I can work with? Thanks.


Solution

  • #<Geom::BoundingBox:0x0000005063c360>
    

    What does this mean[?]

    Its the object being returned by model.bounds and being set to model_bb. Whilst working with Ruby via the console it will echo back the last returned result.

    how can I turn these into x,y,z coordinates that I can work with?

    You can retrieve each of the 8 Point3d corners of the Bounding Box with its corner(corner_index) method like so

    points = (0..7).map { |n| model_bb.corner(n) }
    

    You can find out more information by reading the SketchUp Ruby API Documentation