Close



Results 1 to 10 of 32

Threaded View

  1. #6
    Technician
    Join Date
    Mar 2021
    Posts
    63
    [QUOTE=curious aardvark;150378]well that is insanely long for a simple box generator. I suppose it does have a lid as well.
    [quote]
    Yes. Here's a photo:
    Well, I inserted one but it didn't show up! I'll try a link:

    https://www.dropbox.com/s/44mfvefp2p...id-2.jpg?raw=1

    I'll look into the speed issue, but others don't appear to think that's an unrealistic time. I used the default settings for everything on my Ender 3 V2

    But honestly you are better off starting by making your own. #
    A simple box is a great way to start:

    difference(){
    cube ([50,20,10],center=true);
    translate([0,0,2]) cube ([46,16,10],center=true);
    } // end difference

    viola - a box with 2mm thick walls and base and 50mm long by 20 wide and 10mm tall - good for screws and bits.
    I know that to you it must appear trivially simple. But, as a complete beginner, the only line of your code that I understand is the cube definition, syntax apart! But I think I can learn a great deal from this thread if you'll all bear with me!

    To make this parametric you just need to indulge in a little algebra and throw in some variables
    Is the 'parametric' (which I interpret as 'something specified by using parameters') defined as a sort of function? In this example is it Difference? And do all its commands (right label?) have to be in curly brackets? So with these four lines (you say two later?) we are making part of a box by subtracting one cube from another?

    That's not immediately intuitive, right? I'd assumed I'd build it as I would with simple woodwork, by making six rectangles and gluing or pinning five together, and then thinking how to handle the sixth (the lid). But presumably that wouldn't work for 3D printing, as the main five pieces would not be joined?


    And that's a 2 line cubic box generator.

    To make a different shape box you use cylinders instead of cubes and change the number of facets to the shape you want.
    so a 4 facet cylinder is a cube and a 3 facet cylinder is a triangle. You use a resize command to change the shape from a fixed diameter 'cylinder' to the length and breadth you specify. :
    I'll be happy to stay exclusively with cubes for now, thanks. Although I will soon want to add a few holes. This new 3D printing hobby will complement the stuff I do with electronics projects. So cases in particular are my initial interest.

    Cases.jpg

    2 line infinite shape box generator.

    So you start with a simple centred cube and difference a smaller cube - if you center it you don't have to muck about with moving it about to get it centred yourself.
    wall thickness happens on both sides of the shape - so you always have to multiply it by 2.
    Ah, OK, I think that's not only answered my question earlier but also my puzzlement that when I changed the 'center=true' to 'center=false' I got this:

    SimplestBox-NotCentred.jpg


    In the second example you use algebra to make the sizes variable.
    And in the third example you use different number sided 'cylinders' to change the number of sides of the shape.
    A resize command over rules all subsequent sizes - so it doesn't matter what size you make the original cylinder.

    I don't do programming - so i approach openscad very differently to programmers.
    I like to make it easy to read what I've done - so I use short variables and never indent anything. Most programmers use whole sentences for variables and end up with something almost unguessable - in my opinion ;-)

    The beauty of openscad is that you can write the scripts any way you like.
    The way I approach a design problem is also simple.
    work out what you want to make and then break it down into simple shapes. Then work out what shapes need to be added or removed and where they need to be and go from there.

    It does seem daunting at first.
    But once you've got your own script style that you can read and have worked out what the commands do - it's really a lot better and more precise than moving stuff around with a mouse.

    And so much faster !

    Also - and one of it's best points - everything generated by a script is a solid shape that will print.
    No errors.

    As far as all the different brackets and why they are where there are, goes, don't sweat it.
    Just get into the habit of putting them where the cheatsheet says they should go and don't worry about what they do :-)

    That's an extremely helpful post, thanks so much. I'm going to study and play with your cube but I'm afraid I will be back quite soon asking stuff like:
    - How do I get a bottom on the box?
    - And a hole of R mm diameter in one of the surfaces?

    The reason I started with thingiverse was because although I might be able to manage a very basic box myself, I was sure that other essential elements would be beyond me. Such as lids (either sliding or screw-on), and holes, and grooves on the sides for circuit boards, etc.

    I have been considering trying FreeCAD but must say I do like openSCAD and think that's the one I'll be using.

    Terry, UK
    Attached Images Attached Images

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •