Zoom To Selection

Goal: zoom to node or selected nodes.

Zoom to single node

function zoomToNode(node) {
  var box=node.getBoundingBox(node.getWTM(),null);
  if(box)view3d.zoomToFitBox(null,box,iv.VIEW_TRANSITION);
}

Zoom to Selection

function zoomToSelection() {
 var a=view3d.space.getSelection();
  if(a && a.length) {    var box=null;
   for(var i=0;i<a.length;i++)
   {
    var node=a[i];
    box=node.getBoundingBox(node.getWTM(),box);
   }
  if(box)view3d.zoomToFitBox(null,box,iv.VIEW_TRANSITION);
  }else  
    view3d.zoomToFit(null,iv.VIEW_TRANSITION); // zoom to all
}	

In this article