How to access bound sides of entity

Hi, how can i access sides of bounds of entity or group or compunents. i mean in some situation we need this part of bounds for example sketchup 2020 make new snap when you choose Move tool and press Alt key you can see snap point in side of entity and so on.


i want to access normal point of bound side :index_pointing_at_the_viewer:

Use the #bounds method to get a BoudingBox object, then access it’s #corner points, #center, etc.

Using the corner points for example, you can calculate the midpoint along the bounding frame.

bbox = entity.bounds
point1 = bbox.corner(0) # left front bottom
#=> Geom::Point3d(0, 0, 0)
point2 =  bbox.corner(1) # right front bottom
#=> Geom::Point3d(10, 10, 0)
midpoint = Geom.linear_combination(0.5, point1, 0.5, point2)
#=> Geom::Point3d(5, 5, 0)
2 Likes

Note that .bounds on a group/component instance doesn’t return the same as the visible boundingbox.

For that you need to take the bounds of the definition and transform the points from that with the transformation to the instance.

1 Like