// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
//! Bill Of Materials generation via echo and the ```bom.py``` script. Also handles exploded assembly views and posing. Assembly instructions can precede the module
//! definition that makes the assembly.
//!
//! The example below shows how to define a vitamin and incorporate it into an assembly with sub-assemblies and make an exploded view. The resulting flat BOM is shown but
//! heirachical BOMs are also generated for real projects.
//
functionbom_mode(n=1)=$_bom>=n&&(is_undef($on_bom)||$on_bom);//! Current BOM mode, 0 = none, 1 = printed and routed parts and assemblies, 2 includes vitamins as well
functionexploded()=is_undef($exploded_parent)?$exploded:0;//! Returns the value of ```$exploded``` if it is defined, else ```0```
functionshow_supports()=!$preview||exploded();//! True if printed support material should be shown
moduleno_explode()let($exploded_parent=true)children();//! Prevent children being exploded
moduleno_pose()let($posed=true)children();//! Force children not to be posed even if parent is
moduleexplode(d,explode_children=false,offset=[0,0,0]){//! Explode children by specified Z distance or vector ```d```, option to explode grand children
modulepose(a=[55,0,25],t=[0,0,0],exploded=undef)//! Pose an STL or assembly for rendering to png by specifying rotation ```a``` and translation ```t```, ```exploded = true for``` just the exploded view or ```false``` for unexploded only.
modulepose_hflip(exploded=undef)//! Pose an STL or assembly for rendering to png by flipping around the Y axis, ```exploded = true for``` just the exploded view or ```false``` for unexploded only.
modulepose_vflip(exploded=undef)//! Pose an STL or assembly for rendering to png by flipping around the X axis, ```exploded = true for``` just the exploded view or ```false``` for unexploded only.