class BoundingBox |
Parent: Object |
|
Methods:new, add, center, clear, contains?, corner, depth, diagonal, empty?, height, intersect, max, min, valid?, width |
|
Sample Code:boundingboxtests.rb |
|
Class Methods |
new |
The new method is used to create a new, empty, bounding box. |
Syntax: |
boundingbox = Geom::BoundingBox.new |
Arguments: |
|
Return Value: |
boundingbox – a BoundingBox object if successful |
Comments: |
|
Example: |
boundbox = new Geom::BoundingBox.new if (boundbox) |
Instance Methods |
add |
The add method is used to add a point, or other bounding boxes, to the bounding box. The size of the bounding box will increase as necessary to accommodate the new points or bounding boxes. |
Syntax: |
boundingbox = boundingbox.add point boundingbox = boundingbox.add point1, point2, ... boundingbox = boundingbox.add boundingbox boundingbox = boundingbox.add [point1, point2, ...] |
Arguments: |
point1, point2, ... – A Point3d object boundingbox – a BoundingBox object |
Return Value: |
boundingbox – the new, resized, BoundingBox object if successful |
Comments: |
Adding one point to an empty bounding box, does not increase the size of the bounding box. You must add at least two points before methods, such as BoundingBox.diagonal, will return a size greater than zero. |
Example: |
model = Sketchup.active_model # Get the bounding box associated with
the model. There will not be any size to the bounding box |
center |
The center method is used to retrieve the Point3d object at the center of the bounding box. |
Syntax: |
point = boundingbox.center |
Arguments: |
|
Return Value: |
point – the Point3d at the center of the bounding box if successful |
Comments: |
|
Example: |
# There will not be any size to your bounding box until you add at least two points prior to calling model.bounds boundbox = model.bounds center = boundbox.center UI.messagebox center |
clear |
The clear method is used to clear a bounding box. |
Syntax: |
boundingbox = boundingbox.clear |
Arguments: |
|
Return Value: |
boundingbox - the BoundingBox object which was cleared |
Comments: |
A cleared BoundingBox does not have a size greater than zero until you add at least two points or another bounding box. |
Example: |
# There will not be any size to your bounding box until you add at least two points prior to calling model.bounds boundbox = model.bounds bounding = boundbox.clear |
contains? |
This method is used to determine if a bounding box contains a specific Point3d or BoundingBox object. |
Syntax: |
status = boundingbox.contains? point | boundingbox |
Arguments: |
point – a Point3d object boundbox – a BoundingBox object |
Return Value: |
status = true if successful (bounding box contains a Point3d or BoundingBox object), or false if unsuccessful. |
Comments: |
|
Example: |
point = Geom::Point3d.new(100,200,300) if (status) |
corner |
The corner method is used to retrieve a point object at a specified corner of the bounding box. |
Syntax: |
point = boundingbox.corner corner |
Arguments: |
corner – a number (from 0 to 7) representing point at the corner you want to retrieve. |
Return Value: |
point – a Point3d object if successful |
Comments: |
There are 8 corners to a bounding box, identified by the numbers 0 through 7. Points are returned in the currently set units (inches, by default). |
Example: |
# Add two points point = Geom::Point3d.new(100,200,300) model = Sketchup.active_model #
Returns a point in the form of three coordinates, such as 6”, 0”, 0” |
depth |
The depth method is used to retrieve the depth of the bounding box. |
Syntax: |
depth = boundingbox.depth |
Arguments: |
|
Return Value: |
depth – the depth of the bounding box if successful |
Comments: |
The depth is returned in the currently set units (inches, by default). |
Example: |
# Add two points model
= Sketchup.active_model |
diagonal |
The diagonal method is used to get the length of the diagonal of the bounding box. |
Syntax: |
diagonal = boundingbox.diagonal |
Arguments: |
|
Return Value: |
diagonal – the size of the diagonal for the bounding box if successful |
Comments: |
The diagonal is returned in the currently set units (inches, by default). |
Example: |
#
Add two points model = Sketchup.active_model |
empty? |
The empty? method is used to determine if a bounding box is empty (such as if the bounds have not been set.) |
Syntax: |
status = boundingbox.empty? |
Arguments: |
|
Return Value: |
status – true if the bounding box is empty, false if it is not empty |
Comments: |
|
Example: |
point
= Geom::Point3d.new(100,200,300) model = Sketchup.active_model |
height |
The height method is used to retrieve the height of the bounding box. |
Syntax: |
height = boundingbox.height |
Arguments: |
|
Return Value: |
height – the height of the bounding box |
Comments: |
The height is returned in the currently set units (inches, by default). |
Example: |
point
= Geom::Point3d.new(100,200,300) model = Sketchup.active_model # Returns the length |
intersect |
The intersect method is used to retrieve a bounding box that is the result of intersecting one bounding box with another. |
Syntax: |
boundingbox = boundingbox1.intersect boundingbox2 |
Arguments: |
boundingbox2 – a second boundbox which might intersect boundingbox1 |
Return Value: |
boundingbox – the resulting BoundingBox object if successful, an empty BoundingBox object if unsuccessful. |
Comments: |
Adding one point to an empty bounding box, does not increase the size of the bounding box. You must add at least two points before methods, such as BoundingBox.diagonal, will return a size greater than zero. |
Example: |
|
max |
The max method is used to retrieve the Point3d object where x, y and z are maximum in the bounding box. |
Syntax: |
point = boundingbox.max |
Arguments: |
|
Return Value: |
point – a Point3d object representing the point where x, y, and z are the maximum in the bounding box. |
Comments: |
If you attempt to call the max method on an empty bounding box, you will receive a very large negative number. |
Example: |
point
= Geom::Point3d.new(100,200,300) model = Sketchup.active_model |
min |
The min method is used to retrieve the Point3d where x, y and z are minimum in the bounding box. |
Syntax: |
point = boundingbox.max |
Arguments: |
|
Return Value: |
point – a Point3d object representing the point where x, y, and z are the maximum in the bounding box. |
Comments: |
If you attempt to call the max method on an empty bounding box, you will receive a very large positive number. |
Example: |
point
= Geom::Point3d.new(100,200,300) model = Sketchup.active_model |
valid? |
The valid method is used to determine if a bounding box is valid (contains points). |
Syntax: |
status = boundingbox.valid? |
Arguments: |
|
Return Value: |
status – true if the bounding box is valid (not empty), false if it is not valid (empty) |
Comments: |
|
Example: |
point
= Geom::Point3d.new(100,200,300) model = Sketchup.active_model if (status) |
width |
The width method is used to retrieve the width of the bounding box. |
Syntax: |
width = boundingbox.width |
Arguments: |
|
Return Value: |
width – the width of the bounding box if successful |
Comments: |
The diagonal is returned in the currently set units (inches, by default). |
Example: |
point
= Geom::Point3d.new(100,200,300) model = Sketchup.active_model # Returns the width UI.messagebox.width |