### discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

### Apparently I don't understand modulo

GH
gene heskett
Sat, Nov 11, 2023 8:46 PM

On 11/11/23 15:04, Rogier Wolff wrote:

On Fri, Nov 10, 2023 at 08:18:13PM -0500, gene heskett via Discuss wrote:

Ok, I've done that and it works up to a final target of .90 but
fails for target values of 1.0 and up.  So what I and going to do is
use that basic code and add an offset to the var i to make the rest
of this up to about 4.0. What I'm making is a gauge set, with the
buttress thread increasing from a starter value to that + the amount
printed on the tab.

In openscad it might be better to just structure your loops with an
integer as a loop parameter if you want to do this kind of stuff.

So instead of:

``````for (x=[.10:.10:1.5])
for (y=[.15:.15:1.5]) {
if (x % .20) ...
}
``````

you do:

``````for (ix=[1:1:15])
for (iy=[1:1:10]) {
x = ix * .10;
y = iy * .15
if (ix % 2) ...
}
``````

Good, practical advice Roger, I'll try to remember it next time I do
some repetitive thing that increments a size or???  This may not be
optimum, but I do have it working.  And about to start my 2nd run with a
new printer, an  QIDI X-MAX3, a heavy beast with a 325mm*3 build volume,
runs klipper FAST by remote control.  And sorting a slicer I've never
seen before, a bit like sorting rattlesnakes.  If I don't get bit, a
don't learn...

Thank, take care & stay well.

Roger.

## Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

• Louis D. Brandeis
On 11/11/23 15:04, Rogier Wolff wrote: > On Fri, Nov 10, 2023 at 08:18:13PM -0500, gene heskett via Discuss wrote: >> Ok, I've done that and it works up to a final target of .90 but >> fails for target values of 1.0 and up. So what I and going to do is >> use that basic code and add an offset to the var i to make the rest >> of this up to about 4.0. What I'm making is a gauge set, with the >> buttress thread increasing from a starter value to that + the amount >> printed on the tab. > > In openscad it might be better to just structure your loops with an > integer as a loop parameter if you want to do this kind of stuff. > > So instead of: > > for (x=[.10:.10:1.5]) > for (y=[.15:.15:1.5]) { > if (x % .20) ... > } > > you do: > > for (ix=[1:1:15]) > for (iy=[1:1:10]) { > x = ix * .10; > y = iy * .15 > if (ix % 2) ... > } Good, practical advice Roger, I'll try to remember it next time I do some repetitive thing that increments a size or??? This may not be optimum, but I do have it working. And about to start my 2nd run with a new printer, an QIDI X-MAX3, a heavy beast with a 325mm*3 build volume, runs klipper FAST by remote control. And sorting a slicer I've never seen before, a bit like sorting rattlesnakes. If I don't get bit, a don't learn... Thank, take care & stay well. > > > Roger. > > Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis
Replying to: