Openscad code gen

This commit is contained in:
Lev Nikonov 2025-12-02 22:10:33 +05:00
parent 4fd92e8d66
commit ff142da017
9 changed files with 86 additions and 65 deletions

View file

@ -5,7 +5,7 @@
\-----------------------------------------------*/
include <Driver_01.lib>
include <Package.lib>
Convexity = 2;
Convexity = 4;
board_h = 1.500;
@ -23,14 +23,15 @@ MODE = 1; // 1: full 3D view
// 8: custom lateral projection
// 9: custom frontal projection
// 10: custom combo projection
// 11: frontal 3D section for Custom
// 12: lateral 3D section for Custom
// 13: top 3D section for Custom
// 11: frontal 3D section
// 12: lateral 3D section
// 13: top 3D section
// 14: boolean difference (makes
// holes in the Custom objects
// using 3d-models of pcb parts).
dir = 0; // view direction for 6...13 modes
sector = 4;// double-sided section for modes 11, 12, 13
pdist = 20;// distance between projections for mode 10
@ -41,12 +42,12 @@ drw_board_outline = (MODE!=4&&MODE!=5&&MODE!=14)?1:0;
drw_copper = (MODE<4||MODE>10)?1:0;
drw_holes = (MODE<4||MODE>10)?1:0;
drw_pads = (MODE<4||MODE>10)?1:0;
drw_Driver_01_C0402 = E;
drw_Driver_01_RTLECS = E;
drw_Driver_01_CD54 = E;
drw_Driver_01_MSOP_8T = E;
drw_Driver_01_SMTDIODE = E;
drw_Driver_01_CC0805 = E;
drw_Driver_01_C0402 = E; // controls Draw_Driver_01_C0402();
drw_Driver_01_RTLECS = E; // controls Draw_Driver_01_RTLECS();
drw_Driver_01_CD54 = E; // controls Draw_Driver_01_CD54();
drw_Driver_01_MSOP_8T = E; // controls Draw_Driver_01_MSOP_8T();
drw_Driver_01_SMTDIODE = E; // controls Draw_Driver_01_SMTDIODE();
drw_Driver_01_CC0805 = E; // controls Draw_Driver_01_CC0805();
@ -59,6 +60,7 @@ to use this option*/
module Main (custom=true)
{
// (this module cannot be modified by the user)
Pcb_Driver_01(frozen);
if(custom) Custom();
}
@ -76,14 +78,16 @@ module Custom ()
rotate([0,0,0])
cube(10);
*/
// add any PCB from the project folder,
// any pcb in the project folder will require
// the <.lib> header (See top) to be included:
render(Convexity)
translate([-6,-3.5,-9.000])
Pcb_Package (true);
// end of user field
}
}
@ -91,7 +95,7 @@ module Custom ()
//// Drawing
cube_scaleX = 1.0;// (cube sizeX for 4,5,11,12,13 modes)
cube_scaleX = 2.0;// (cube sizeX for 4,5,11,12,13 modes)
cube_scaleY = 1.0;// (cube sizeY for 4,5,11,12,13 modes)
cube_scaleZ = 1.0;// (cube sizeZ for 4,5,11,12,13 modes)
if (MODE == 1)
@ -108,12 +112,12 @@ else if (MODE == 3)
else if (MODE == 4)
projection()difference(){
Main(0);
Draw_Driver_01_CUBE(0, frozen);}
Draw_Driver_01_CUBE(0, frozen, 0);}
else if (MODE == 5)
//mirror([1, 0, 0])
projection()difference(){
Main(0);
Draw_Driver_01_CUBE(1, frozen);}
Draw_Driver_01_CUBE(1, frozen, 0);}
else if (MODE == 6)
projection()
rotate([0, dir?-90:90, 0])
@ -145,7 +149,7 @@ else if (MODE == 10)
rotate([0, dir?-90:90, 0])
Main(0);
}
render()// combines intersecting projections
render()// (combines intersecting projections)
{
projection(true)
translate([0, 0, frozen?(dir?originY_Driver_01:-originY_Driver_01):0])
@ -161,35 +165,45 @@ else if (MODE == 10)
}
else if (MODE == 11)
{
PcbFull = 0; // make 1 for full pcb view
difference(){
if(PcbFull) Custom();
else Main();
color("white")
translate([0, frozen?-originY_Driver_01:0, frozen?(dir?-max_height_Driver_01/2:max_height_Driver_01/2):0])
rotate([dir?90:-90, 0, 0])
Draw_Driver_01_CUBE(0, frozen);}
if(PcbFull) Main(0);
PcbFull = 0; // make 1 for full pcb view
//projection() rotate([-90,0,0])
{
if(PcbFull) Main(0);
difference(){
if(PcbFull) Custom();
else Main();
color("white")
translate([0, frozen?-originY_Driver_01:0, frozen?(dir?-max_height_Driver_01/2:max_height_Driver_01/2):0])
rotate([dir?90:-90, 0, 0])
Draw_Driver_01_CUBE(0, frozen, sector);}
}
}
else if (MODE == 12)
{
PcbFull = 0; // make 1 for full pcb view
difference(){
if(PcbFull) Custom();
else Main();
color("white")
translate([frozen?-originX_Driver_01:0, 0, frozen?(dir?max_height_Driver_01/2:-max_height_Driver_01/2):0])
rotate([0, dir?90:-90, 0])
Draw_Driver_01_CUBE(0, frozen);}
if(PcbFull) Main(0);
PcbFull = 0; // make 1 for full pcb view
//projection() rotate([0,90,0])
{
if(PcbFull) Main(0);
difference(){
if(PcbFull) Custom();
else Main();
color("white")
translate([frozen?-originX_Driver_01:0, 0, frozen?(dir?max_height_Driver_01/2:-max_height_Driver_01/2):0])
rotate([0, dir?90:-90, 0])
Draw_Driver_01_CUBE(0, frozen, sector);}
}
}
else if (MODE == 13)
{
difference(){
Custom();
translate([0,0,0])
Draw_Driver_01_CUBE(dir?1:0, frozen);}
Main(0);
//projection()
{
Main(0);
difference(){
Custom();
color("white")
translate([0,0,0])
Draw_Driver_01_CUBE(dir?1:0, frozen, sector);}
}
}
else if (MODE == 14)
difference(){

View file

@ -1,11 +1,11 @@
//============================================
// Code builder for OpenScad via Freepcb-2
// Author: niconson.com (c) 2014-2025
// Sites: https://niconson.com/freepcb2
// https://github.com/niconson
// Code builder for OpenScad
// Site: https://github.com/niconson
//============================================
// Polylines
module Poly1_Driver_01_C0402 ()
{

View file

@ -1,11 +1,11 @@
//============================================
// Code builder for OpenScad via Freepcb-2
// Author: niconson.com (c) 2014-2025
// Sites: https://niconson.com/freepcb2
// https://github.com/niconson
// Code builder for OpenScad
// Site: https://github.com/niconson
//============================================
// Polylines

View file

@ -1,11 +1,11 @@
//============================================
// Code builder for OpenScad via Freepcb-2
// Author: niconson.com (c) 2014-2025
// Sites: https://niconson.com/freepcb2
// https://github.com/niconson
// Code builder for OpenScad
// Site: https://github.com/niconson
//============================================
// include <Driver_01_CD54.lib>
// include <Package.lib>

View file

@ -8,19 +8,26 @@
originX_Driver_01 = -22.000;
originY_Driver_01 = -15.250;
max_height_Driver_01 = 44.000;
module Draw_Driver_01_CUBE(side, var)
module Draw_Driver_01_CUBE(side, frozen, space)
{
if (is_undef(cube_scaleX) || is_undef(cube_scaleY) || is_undef(cube_scaleZ))
{
translate([max_height_Driver_01/2, max_height_Driver_01/2, 0])
translate([var?0:originX_Driver_01, var?0:originY_Driver_01, side?max_height_Driver_01/2-board_h:-max_height_Driver_01/2])
translate([frozen?0:originX_Driver_01, frozen?0:originY_Driver_01, side?max_height_Driver_01/2-board_h:-max_height_Driver_01/2])
cube(max_height_Driver_01, center=true);
}
else
{
translate([max_height_Driver_01/2, max_height_Driver_01/2, 0])
translate([var?0:originX_Driver_01, var?0:originY_Driver_01, side?(max_height_Driver_01/2*cube_scaleZ)-board_h:(-max_height_Driver_01/2*cube_scaleZ) ])
translate([frozen?0:originX_Driver_01, frozen?0:originY_Driver_01, side?(max_height_Driver_01/2*cube_scaleZ)-board_h:(-max_height_Driver_01/2*cube_scaleZ) ])
scale([cube_scaleX, cube_scaleY, cube_scaleZ])
cube(max_height_Driver_01, center=true);
if(space > 1)
{
push_direction = side ? -1 : 1;
spaceAxisForCube = space + (max_height_Driver_01 * cube_scaleZ);
translate([0, 0, push_direction * spaceAxisForCube])
Draw_Driver_01_CUBE(side, frozen, 0);
}
}
}

View file

@ -1,11 +1,11 @@
//============================================
// Code builder for OpenScad via Freepcb-2
// Author: niconson.com (c) 2014-2025
// Sites: https://niconson.com/freepcb2
// https://github.com/niconson
// Code builder for OpenScad
// Site: https://github.com/niconson
//============================================
// Polylines
module Poly3_Driver_01_MSOP_8T ()
{

View file

@ -1,11 +1,11 @@
//============================================
// Code builder for OpenScad via Freepcb-2
// Author: niconson.com (c) 2014-2025
// Sites: https://niconson.com/freepcb2
// https://github.com/niconson
// Code builder for OpenScad
// Site: https://github.com/niconson
//============================================
// Polylines

View file

@ -1,11 +1,11 @@
//============================================
// Code builder for OpenScad via Freepcb-2
// Author: niconson.com (c) 2014-2025
// Sites: https://niconson.com/freepcb2
// https://github.com/niconson
// Code builder for OpenScad
// Site: https://github.com/niconson
//============================================
// Polylines
module Poly13_Driver_01_SMTDIODE ()
{

Binary file not shown.