[OpenSCAD] for loop implicid union.

Rogier Wolff R.E.Wolff at BitWizard.nl
Sat Sep 1 14:48:22 EDT 2018


On Sat, Sep 01, 2018 at 10:11:16AM +0100, nop head wrote:
> Yes its a major problem but it isn't just for loops. Any openscad module,
> like translate(), etc, can only return one child, so it has to union its
> results.

> On 1 September 2018 at 09:45, Rogier Wolff <R.E.Wolff at bitwizard.nl> wrote:
> 
> > Hi,
> >
> > I have this puzzle I'm making:
> >     makepuzzle (pitch=35, theblock = bn, real=1)
> >       {
> >         rotate ([  0,  0,  0]) beam (r=bs, height=bl);
> >         rotate ([  0,180,  0]) beam (r=bs, height=bl);
> >         rotate ([  0, 90, 90]) beam (r=bs, height=bl);
> >         rotate ([  0,-90,-90]) beam (r=bs, height=bl);
> >         rotate ([ 90,  0, 90]) beam (r=bs, height=bl);
> >         rotate ([-90,  0,-90]) beam (r=bs, height=bl);
> >       }

I have found a reasonably elegant solution to my problem:

I have now the "one beam" module do the rotations (and colors)

So.. I'd like to use a loop here, but can't. 
  makepuzzle (pitch=35, theblock = bn, real=1) {
    onebeam (0);
    onebeam (1);
    onebeam (2);
    onebeam (3);
    onebeam (4);
    onebeam (5);
  }

I'm working on a design where the number of pieces is not six, so
that'll be annoying. But other than that... things are looking good.


For printing I need to rotate the stuff back to a fixed orientation 
so while forward rotation is: 
  rotate (lor[num]);
(list-of-rotations). 

the inverse is: 
  module rrotate (v)
  {
    rotate ([-v[0],0,0])
    rotate ([0,-v[1],0])
    rotate ([0,0,-v[2]])
      children ();
  }


	Roger. 

-- 
** R.E.Wolff at BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **
**    Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233    **
*-- BitWizard writes Linux device drivers for any device you may have! --*
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.



More information about the Discuss mailing list