Hi Nemoz,
re:
> Could you please clarify the correct and reliable way to retrieve the currently selected object(s)
> (including faces of solids and standalone surfaces) from within a custom HTML
> command's JavaScript?
It's moi.geometryDatabase.getSelectedObjects().
If that is not working for your script, please post the script and .3DM file, or send it to me at moi@moi3d.com so I can try to reproduce the problem over here.
> Retrieving dimensions and properties of 3D solids: Once a solid is selected, what are the appropriate API
> methods to obtain its bounding box, volume, surface area, or other geometric properties necessary for CAM
> calculations?
For getting a bounding box:
var bbox = obj.getBoundingBox( true /* Use high accuracy bounds */ );
Bounding box has these properties:
bbox.min
bbox.max
bbox.center
bbox.xLength
bbox.yLength
bbox.zLength
bbox.diagonalLength
Calculating surface area:
code:
function GetObjectArea( objects )
{
moi.geometryDatabase.deselectAll();
objects.setProperty( 'selected', true );
var area = moi.ui.propertiesPanel.calcSurfaceArea();
moi.geometryDatabase.deselectAll();
return area;
}
Calculating volume:
code:
function GetObjectVolume( objects )
{
moi.geometryDatabase.deselectAll();
objects.setProperty( 'selected', true );
var volume = moi.ui.propertiesPanel.calcSolidVolume();
moi.geometryDatabase.deselectAll();
return volume;
}
- Michael
|