Results 1 to 10 of 24
Threaded View
-
04-04-2018, 03:02 PM #13
- Join Date
- Jun 2014
- Posts
- 885
You won't want to import a known defective STL into OpenSCAD. The idea is that I can help by recreating the model in OpenSCAD and provide you with an error free STL, or you can learn to use OpenSCAD to construct the part yourself.
Let's say the lid is 5.5 x 6.25 x 0.25 dimensions.
It's better to use metric in OpenSCAD, converting: 139.7 x 158.75 x 6.35, rounding for ease of use: 140 x 159 x 6. If you require fractional millimeter precision, it's an easy matter to plug the more accurate numbers into the code.
Code:module lid(){ cube([140, 159, 6]); } lid();
Code:lid_w = 140; lid_d = 159; lid_t = 6; module lid(){ cube([lid_w, lid_d, lid_t]); } lid();
I wanted to expand a bit on the parameters part and got carried away. OpenSCAD allows you to pass parameters to modules when you call the module. I colored each panel differently, making it easier to see and identify them. Keep in mind that OpenSCAD doesn't add color to the model and the colors will vanish when the model is rendered (F6), but it does show when the model is previewed (F5).
Code:lid_w = 140; // also base width lid_d = 159; // also base depth lid_t = 6; // also wall thickness wall_h = 25; // arbitrary guess at wall height addabit = 0.1; // fudge factor for clean unions module lid(color_choice_lid){ color(color_choice_lid) cube([lid_w, lid_d, lid_t]); } module left_wall(color_choice_left){ translate([0, 0, lid_t - addabit]) // elevate wall to be not quite above floor color(color_choice_left) cube([lid_t, lid_d, wall_h]); } module right_wall(color_choice_right){ translate([lid_w - lid_t, 0, 0]) // use left_wall module, shift it over color(color_choice_right) left_wall(); } module front_wall(color_choice_front){ translate([0, 0, lid_t - addabit]) // same elevation as before color(color_choice_front) cube([lid_w, lid_t, wall_h]); } module back_wall(color_choice_back){ translate([0, lid_d - lid_t, 0]) color(color_choice_back) front_wall(); } lid("black"); left_wall("yellow"); right_wall("green"); front_wall("blue"); back_wall("red");
The great advantage of using parameters is that you can change the value in the assignment area and IF the code is well-written, everything adjusts properly. A good way to test code is to change these figures to ensure that everything else does change appropriately.
I'm not a code wizard, but find this program to be great fun for the brain cells and very useful overall. There's a strong possibility that just about anyone else familiar with OpenSCAD can improve on my thrown-together code. I didn't put a lot of work into it and may have made some trivial errors, but the model generated is manifold and fits the parameters. Advanced coding escapes me.
New to 3d printing looking for...
05-20-2024, 12:56 AM in Tips, Tricks and Tech Help