scad-common/dsl/component.scad
2019-02-23 20:33:01 +01:00

69 lines
1.2 KiB
OpenSCAD

use <../scad-views.scad>;
use <./modify.scad>;
HUGE=2000;
function _contains(val, list)=len([for (i = list) if (i==val) i]) > 0;
module c(name) {
if($sc_comp == name) children();
}
module v(name) {
if($sc_comp_view == name) children();
}
module mv(names) {
if(_contains($sc_comp_view,names)) children();
}
module mc(names) {
if(_contains($sc_comp,names)) children();
}
module _v(name) {
$sc_comp_view=name;
children();
}
module _c(name) {
$sc_comp = name;
children();
}
module from_2d_views() {
intersection() {
side_view()
vmove(z=-HUGE/2)
vextrude(HUGE)
_v("side")
construct() children();
top_view()
vmove(z=-HUGE/2)
vextrude(HUGE)
_v("top")
construct() children();
front_view()
vmove(z=-HUGE/2)
vextrude(HUGE)
_v("front")
construct() children();
}
}
module c_construct() {
construct() {
add() move(1000,1000,1000) cube(10);
remove() move(995,995,995) cube(20);
_v("3d") children();
add() from_2d_views() children();
}
}
module 3d_view() {
children();
}