Hello,
Trying to do a simple "toggle" variable, 0-1-0-1... inside a for loop, using
the following code:
assign( k = (k==1) ? 0 : 1)
"k" is not changing as I expected.
ANY help or thoughts appreciated!
Bill Martin
--
View this message in context: http://forum.openscad.org/should-this-work-tp10351.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
The documentation says Assign: "Set variables to a new value for a sub-tree."
for (i = [10:50])
{
assign (angle = i360/20, distance = i10, r = i*2)
{ // subtree starts here
rotate(angle, [1, 0, 0])
translate([0, distance, 0])
sphere(r = r);
} // subtree ends here
}
So you can't use it like that.
--
View this message in context: http://forum.openscad.org/should-this-work-tp10351p10352.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
for(i=[0:10]) {
assign(k=i%2){
echo(i=i,k=k);
}
}
Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/should-this-work-tp10351p10357.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
for(i=[0:10]) {
assign(k=i%2){
echo(i=i,k=k);
}
}
It used to...
Last night I did a git pull / compile and discovered that Something
Changed in the last week or two, as a conditional test that formerly
worked no longer did.
The original test:
else if ((!(iy % 2) && !(ix % 2)))
What works now:
else if ((0 == (iy % 2)) && (0 == (ix % 2)))
The ix and iy integers iterate from 0 to maximum values, generating
coordinates at discrete points in the plane. At positions where the
indexes are both even, the program generates a particular type of chain
mail link.
It seems the ! operator recently stopped turning (integer) 0 into
(boolean) true, as the result remained obstinately false.
A similar test:
if ((iy % 2) && (ix % 2))
continues to function properly, generating a different link shape at the
(odd,odd) points.
The offending conditional is at the bottom of the listing at:
http://softsolder.com/2014/12/04/3d-printed-chain-mail-armor-cosplay-edition/
As the post observes, the code needs refactoring. I recompiled OpenSCAD
and started fiddling, only to discover half the chain mail links were
missing...
--
Ed
softsolder.com
On 12/05/2014 01:40 PM, Ed Nisley wrote:
It used to...
Last night I did a git pull / compile and discovered that Something
Changed in the last week or two, as a conditional test that formerly
worked no longer did.
Yes, there was quite a big change to support the better recursion
handling. I guess that introduced the bug. I'll have a look.
ciao,
Torsten.
On 12/05/2014 01:40 PM, Ed Nisley wrote:
The original test:
else if ((!(iy % 2) && !(ix % 2)))
This should be fixed now.
ciao,
Torsten.
On 12/05/2014 03:09 PM, Torsten Paul wrote:
This should be fixed now.
And so it is!
Thanks...
--
Ed
softsolder.com