OpenSCAD - utility - explode() module

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 12

  • @DavidMcCullough2
    @DavidMcCullough2 7 лет назад +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 7 лет назад +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 3 года назад +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.

  • @theman83744
    @theman83744 4 года назад +1

    really nice tutorial, helped a lot

  • @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.

  • @ericbuijs3043
    @ericbuijs3043 7 лет назад

    Nice how you separate the explode module from the parts.

  • @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 3 года назад +2

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

  • @gilbertodipietro8494
    @gilbertodipietro8494 2 года назад

    The link to damccull at github is not working anymore

  • @r3jjs
    @r3jjs 7 лет назад

    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 7 лет назад +1

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

    • @kernelsmith
      @kernelsmith 9 месяцев назад

      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