OpenSCAD - utility - explode() module

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 เม.ย. 2024
  • This video will show you how to implement an explode module in OpenSCAD.
    The code is available at:
    github.com/mathcodeprint/open...
    Using the children() module you will be able to distribute your parts in any direction at arbitrary distances.
    Thank you for watching my videos, please subscribe, comment and like. Especially if you have already done a module like this
    For this video, this is the version info:
    OpenSCAD Version: 2016.12.22
    System information: Linux 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:44:48 UTC 2015 i686 Ubuntu 14.04.5 LTS 2 CPUs 16777216.00 TB RAM
    Compiler: GCC "4.8.4" 32bit
    Boost version: 1_54
    Eigen version: 3.2.5
    CGAL version, kernels: 4.2, Cartesian, Extended_cartesian, Epeck
    OpenCSG version: OpenCSG 1.3.2
    Qt version: 5.2.1
    QScintilla version: 2.8.1
    MingW build: No
    GLib version: 2.40.2
    libzip version: 0.10.1
    Here are the various jump offs:
    PART 1 - INTRO
    00:00 Widgets to Explode
    PART 2 - Basic Explode
    02:20 Basic Explode
    PART 3 - Distance Parameters and Enable
    05:50 Add the basic distance parameter
    06:40 Create an "enable" argument ( using the if statement )
    09:12 Improve the distance parameter to take a vector.
    PART 4 - Centering and Nesting
    11:37 Nested Explode in Multiple Directions
    12:40 Centering ( if statement and such )
    15:50 Centering ( the math )
    19:04 Effect of nested/un-nested Explode
    PART 5 - Assemblies and Animation
    20:20 Use explode on an assembly
    22:45 Animate the assembly explode
    CLOSING THOUGHTS
    25:00 Closing and Advantages
    NOTES: Jeremy Starcher points out, in the comments, that you could replace the third for loop by processing the 'enable' argument with a conditional operator.
    Check out David McCulloughs Improved verison at :
    gist.github.com/damccull/1a1d...

ความคิดเห็น • 12

  • @DavidMcCullough2
    @DavidMcCullough2 6 ปีที่แล้ว +1

    I enjoyed this tutorial. I actually modified the 'explode' module while watching it to make it cleaner. This one also centers perfectly for any number of objects except for 1, in which case it seems to do nothing. Here is the code:
    gist.github.com/damccull/1a1df5e785e56daf53e0d7b7d8ff219e
    module explode(distance = [10, 0, 0], center = false, enable = true) {
    if(enable){
    offset = center ? (($children * distance) / 2 - distance / 2) * -1 : [0, 0 , 0];
    for(i = [0 : 1 : $children - 1]) {
    translate(i * distance + offset) {
    children(i);
    }
    }
    } else {
    children();
    }
    }
    A little vector math enables the use of a single 'offset' variable. Sane defaults prevent a user from unwittingly breaking the module, and I used an if/else rather than two if's.

    • @DavidMcCullough2
      @DavidMcCullough2 6 ปีที่แล้ว +1

      Paul Randall thanks. I love sharing my way of coding something with people because I find it interesting to see how others code things, so I assume they're interested too.

  • @jhonny1392
    @jhonny1392 2 ปีที่แล้ว +2

    Fantastic Video !. Thanks a lot for sharing with us your knowledge on this program.
    Every time I see a new feature of OpenSCAD *I like it MORE and MORE*
    Thanks again, and many greetings from Santiago de Chile, South America. I´m John.

  • @markwhitis
    @markwhitis 4 ปีที่แล้ว +1

    3:00 - the reason you use $children-1 as the upper end of your loop is that you number children starting at 0. So, if you have five children, they are numbered 0,1,2,3, and 4. There is no child 5.

  • @theman83744
    @theman83744 4 ปีที่แล้ว +1

    really nice tutorial, helped a lot

  • @MichaelJeffers75
    @MichaelJeffers75 6 ปีที่แล้ว +3

    Great content but I can't see the code clearly. Perhaps with future videos increasing font size? Just a suggestion.

    • @jhonny1392
      @jhonny1392 2 ปีที่แล้ว +2

      Put it in 720p and use glasses. Issue solved !.

  • @ericbuijs3043
    @ericbuijs3043 7 ปีที่แล้ว

    Nice how you separate the explode module from the parts.

  • @gilbertodipietro8494
    @gilbertodipietro8494 ปีที่แล้ว

    The link to damccull at github is not working anymore

  • @r3jjs
    @r3jjs 6 ปีที่แล้ว

    In your explode module, rather than duplicating the `for` loop, you could do a
    realDistance = enable ? distance : 0;
    Then translate by `realDistance`. If it is 0, then no translation happens.

    • @DavidMcCullough2
      @DavidMcCullough2 6 ปีที่แล้ว +1

      Jeremy Starcher I had the same idea while watching this tutorial and Incorporated it into my modified example.

    • @kernelsmith
      @kernelsmith 2 หลายเดือนก่อน

      Great stuff. I was going to make a couple comments that were already made (if/else, the ternary operation blah ? true : false, and arrays start at index 0, therefore len is always count - 1). The only thing left might be functionality that was added to openSCAD after u made this video (I have no idea), u can access a vector's first 3 elements with vector.x vector.y and vector.z