I have model in which I create multiple patterns of drill holes.
The pattern and thus the number of holes is optimized for the model size and
"drill size" and other parameters.
The final number of holes drilled is based on a nested group of operations
each fitting in the best pattern. Each hole is separately positioned and
differenced out.
What I want to do is have an accumulator such that each time a cylinder
difference is created to 'drill' a hole I want accumulate the volume of
material removed or at least the area that is cut.
Traditionally this would be done something like:
cut_volume = cut_volume + volume_of_new_cut
Now as I understand it this won't work in OpenSCAD....or maybe I am wrong...
Any suggestions about how to implement this...I don't really want to change
the mechanism for d calculating the holes, I just want to add some code to
keep track and echo the result.
--
Sent from: http://forum.openscad.org/
That would work, as long as the variable is declared on a global scope. I do
it to calculate cost and weight.
--
Sent from: http://forum.openscad.org/
I must be doing something wrong.....
I get only one accumulation them despite multiple adds the value never
changes.
Based on my understanding one Scad this is how it works....so there must be
a trick here I don't grasp.
--
Sent from: http://forum.openscad.org/
You can't accumulate in openscad variables, I don't know why Troberg said
you can.
On Wed, 10 Apr 2019 at 16:40, macdarren macdarren@mac.com wrote:
I must be doing something wrong.....
I get only one accumulation them despite multiple adds the value never
changes.
Based on my understanding one Scad this is how it works....so there must be
a trick here I don't grasp.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
You were right the first time.
cut_volume = cut_volume + volume_of_new_cut
does not work in OpenSCAD. It doesn't work in any context.
On Wed, Apr 10, 2019, at 11:40 AM, macdarren wrote:
I must be doing something wrong.....
I get only one accumulation them despite multiple adds the value never
changes.
Based on my understanding one Scad this is how it works....so there must be
a trick here I don't grasp.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
You can accumulate in C style for loops in list comprehensions.
echo ([for(i = 0, t = 0; i < 10; t = t + i, i = i + 1) if(i == 9) t][0]);
ECHO: 36
On Wed, 10 Apr 2019 at 16:46, nop head nop.head@gmail.com wrote:
You can't accumulate in openscad variables, I don't know why Troberg said
you can.
On Wed, 10 Apr 2019 at 16:40, macdarren macdarren@mac.com wrote:
I must be doing something wrong.....
I get only one accumulation them despite multiple adds the value never
changes.
Based on my understanding one Scad this is how it works....so there must
be
a trick here I don't grasp.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Hmm that looks promising...I use for loops for each section so if I can even
get subsection totals that would be a big improvement...I will try to
implement this and see what happens.
Thanks
--
Sent from: http://forum.openscad.org/
Nobody has mentioned the normal way of accumulating, which is to use
recursion. I don't know if you can apply this to your situation, though.
function sumsqr(n,total=0) = n==0 ? total : sumsqr(n-1,total+n*n);
--
Sent from: http://forum.openscad.org/
nophead wrote
You can't accumulate in openscad variables, I don't know why Troberg said
you can.
You are right, I just checked my code. I log the numbers, and then add stuff
from the log in a separate program. Sorry!
--
Sent from: http://forum.openscad.org/