70001111 Get the entity Bounding Box

Article 70001111
Type Wish
Product WebJS
Version 7011
Date Added 6/26/2017
Fixed 7.7012.0.1 (6/26/2017)
Submitted by Brendan Fry

Summary

I would like to get the action bounding box of an entity in order to find its center point

Solution

In version 7012.0.1 new method GetEntityBBox(object entity) exported.
The GetEntityBBox method returns the passed entity Bounding Box in world coordinate system as an array of 6 doubles(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax).

For example we will finf the center point of an entity by using its boudnig box:

Example:
 
 var center= null;
 var bbox = vdcanvas.GetEntityBBox(entity);
 if (bbox) {//if the entity exist
 var pt1 = vdgeo.newpoint(bbox[0], bbox[1], 0); // The lower left point of the bounding box 
 var pt2 = vdgeo.newpoint(bbox[3], bbox[4], 0); // The upper right point of the bounding box 
 var center = vdgeo.MidPoint(pt1, pt2);// The middle point between lower left and upper right point of the bounding box 
 } 

Send comments on this topic.