GetBoundingBox (Geometry)

Introduced

5.0

Description

Returns the center and extents of a bounding box of the Geometry object. If an input transform is specified, it is applied to the Geometry before the bounding box is calculated.

Scripting Syntax

    Geometry.GetBoundingBox( [Transform] )

C# Syntax

    Object Geometry.GetBoundingBox( Object in_pXfoObjectToBBoxSpace );

Parameters

Parameter | Type | Description
Transform | SITransformation | Transform to be applied to the Geometry before the bounding box is calculated

Return Value

1-dimensional Array containing six values: the X, Y and Z coordinates of the center, followed by the extents of the bounding box in the (local) X, Y, and Z axes.

Examples

1. JScript Example

    /*
       Example using no input transform
    */

    // Create and move (rotate and translate) a torus
    NewScene( null, false ) ;
    var oTorus = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" ) ;
    SelectObj( oTorus ) ;
    Rotate(null, 45, 0, 0, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, 0, null) ;
    Translate(null, 3, 2, 1, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, null, null, 0, null) ;

    // Find the bounding box
    var vba = new VBArray( oTorus.ActivePrimitive.Geometry.GetBoundingBox() ) ;
    var jsa = vba.toArray() ;

    // Report the (local) center and extents
    Application.LogMessage( "center:"  + jsa[0] + ", " + jsa[1] + ", " + jsa[2] ) ;
    Application.LogMessage( "extents:" + jsa[3] + ", " + jsa[4] + ", " + jsa[5] ) ;

2. JScript Example

    // Example using an input transform to preserve scaling
    //

    // Create and move (rotate and translate) a torus
    NewScene( null, false ) ;
    var oTorus = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" ) ;
    SelectObj( oTorus ) ;
    Scale(null, 0.5, 0.5, 1, siAbsolute, siGlobal, siObj, siY, null, null, null, null, null, null, null, 0, null) ;

    oTransform = oTorus.Kinematics.Local.Transform ;

    // Find the bounding box
    var vba = new VBArray( oTorus.ActivePrimitive.Geometry.GetBoundingBox(oTransform) ) ;
    var jsa = vba.toArray() ;

    // Report the (local) center and extents
    Application.LogMessage( "center:" + jsa[0] + ", " + jsa[1] + ", " + jsa[2] ) ;
    Application.LogMessage( "extents:" + jsa[3] + ", " + jsa[4] + ", " + jsa[5] ) ;

    // Build a cube that shows the bounding box
    var oCube = ActiveSceneRoot.AddPrimitive("Cube") ;
    oCube.length = 1 ;
    oCube.PosX = jsa[0] ;
    oCube.PosY = jsa[1] ;
    oCube.PosZ = jsa[2] ;

    oCube.sclx = jsa[3] ;
    oCube.scly = jsa[4] ;
    oCube.sclz = jsa[5] ;

See Also

Geometry.GetBoundingSphere | Geometry.GetBoundingCapsule | GetBBox

Autodesk Softimage v7.5