discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

here's an interesting one to speed-optimize...

J
jon
Sat, Dec 5, 2015 10:43 PM

This one will F5 in a few seconds, but it's been 2.5 hours waiting for
F6 to complete.  I know that it will, because I did it once before.

How would you speed it up?

Jon

$fn = 100;
rch = 0.1;
height = 200; // 30;
diam = 35;

module HoleCylinder()
cylinder(h = 100, d = diam/10);

difference() {
// outer
cylinder(h = height, d = diam);
// inner
translate([0, 0, -1])
cylinder(h = height + 2, d = diam - 4);
// reduce the bottom end
translate([0, 0, -1])
cylinder(h = 10 + 1, d = diam - 2 + rch);
// reduce the top end
translate([0, 0, height - 10])
difference() {
cylinder(h = 10 + 1, d = diam + 1);
cylinder(h = 10 + 1, d = diam - 2 - rch);
}
// holes
for (i = [15:5:height-15])
for (a = [0:15:359])
translate([0, 0, i])
rotate([0, 90, a])
HoleCylinder();
}

This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6 to complete. I know that it will, because I did it once before. How would you speed it up? Jon $fn = 100; rch = 0.1; height = 200; // 30; diam = 35; module HoleCylinder() cylinder(h = 100, d = diam/10); difference() { // outer cylinder(h = height, d = diam); // inner translate([0, 0, -1]) cylinder(h = height + 2, d = diam - 4); // reduce the bottom end translate([0, 0, -1]) cylinder(h = 10 + 1, d = diam - 2 + rch); // reduce the top end translate([0, 0, height - 10]) difference() { cylinder(h = 10 + 1, d = diam + 1); cylinder(h = 10 + 1, d = diam - 2 - rch); } // holes for (i = [15:5:height-15]) for (a = [0:15:359]) translate([0, 0, i]) rotate([0, 90, a]) HoleCylinder(); }
PF
Peter Falke
Sat, Dec 5, 2015 11:01 PM

I would try: make a short cylinder with only one ring of holes, stick this
cylinder in a render(), and add as many of them together as you need.
I would also make the cylinder that punshes the holes as short as possible,
so they will not overlapp.

2015-12-05 23:43 GMT+01:00 jon jon@jonbondy.com:

This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6
to complete.  I know that it will, because I did it once before.

How would you speed it up?

Jon

$fn = 100;
rch = 0.1;
height = 200; // 30;
diam = 35;

module HoleCylinder()
cylinder(h = 100, d = diam/10);

difference() {
// outer
cylinder(h = height, d = diam);
// inner
translate([0, 0, -1])
cylinder(h = height + 2, d = diam - 4);
// reduce the bottom end
translate([0, 0, -1])
cylinder(h = 10 + 1, d = diam - 2 + rch);
// reduce the top end
translate([0, 0, height - 10])
difference() {
cylinder(h = 10 + 1, d = diam + 1);
cylinder(h = 10 + 1, d = diam - 2 - rch);
}
// holes
for (i = [15:5:height-15])
for (a = [0:15:359])
translate([0, 0, i])
rotate([0, 90, a])
HoleCylinder();
}


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I would try: make a short cylinder with only one ring of holes, stick this cylinder in a render(), and add as many of them together as you need. I would also make the cylinder that punshes the holes as short as possible, so they will not overlapp. 2015-12-05 23:43 GMT+01:00 jon <jon@jonbondy.com>: > This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6 > to complete. I know that it will, because I did it once before. > > How would you speed it up? > > Jon > > > $fn = 100; > rch = 0.1; > height = 200; // 30; > diam = 35; > > module HoleCylinder() > cylinder(h = 100, d = diam/10); > > difference() { > // outer > cylinder(h = height, d = diam); > // inner > translate([0, 0, -1]) > cylinder(h = height + 2, d = diam - 4); > // reduce the bottom end > translate([0, 0, -1]) > cylinder(h = 10 + 1, d = diam - 2 + rch); > // reduce the top end > translate([0, 0, height - 10]) > difference() { > cylinder(h = 10 + 1, d = diam + 1); > cylinder(h = 10 + 1, d = diam - 2 - rch); > } > // holes > for (i = [15:5:height-15]) > for (a = [0:15:359]) > translate([0, 0, i]) > rotate([0, 90, a]) > HoleCylinder(); > } > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
AP
Andrew Plumb
Sat, Dec 5, 2015 11:05 PM

Consider whether you really need $fn=100 for all those HoleCylinder() elements. That’s where the bulk of the number-crunching is happening.

Andrew.

On Dec 5, 2015, at 5:43 PM, jon jon@jonbondy.com wrote:

This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6 to complete.  I know that it will, because I did it once before.

How would you speed it up?

Jon

$fn = 100;
rch = 0.1;
height = 200; // 30;
diam = 35;

module HoleCylinder()
cylinder(h = 100, d = diam/10);

difference() {
// outer
cylinder(h = height, d = diam);
// inner
translate([0, 0, -1])
cylinder(h = height + 2, d = diam - 4);
// reduce the bottom end
translate([0, 0, -1])
cylinder(h = 10 + 1, d = diam - 2 + rch);
// reduce the top end
translate([0, 0, height - 10])
difference() {
cylinder(h = 10 + 1, d = diam + 1);
cylinder(h = 10 + 1, d = diam - 2 - rch);
}
// holes
for (i = [15:5:height-15])
for (a = [0:15:359])
translate([0, 0, i])
rotate([0, 90, a])
HoleCylinder();
}


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" -- William Gibson

Me: http://clothbot.com/wiki/ http://clothbot.com/wiki/

Consider whether you *really* need $fn=100 for all those HoleCylinder() elements. That’s where the bulk of the number-crunching is happening. Andrew. > On Dec 5, 2015, at 5:43 PM, jon <jon@jonbondy.com> wrote: > > This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6 to complete. I know that it will, because I did it once before. > > How would you speed it up? > > Jon > > > $fn = 100; > rch = 0.1; > height = 200; // 30; > diam = 35; > > module HoleCylinder() > cylinder(h = 100, d = diam/10); > > difference() { > // outer > cylinder(h = height, d = diam); > // inner > translate([0, 0, -1]) > cylinder(h = height + 2, d = diam - 4); > // reduce the bottom end > translate([0, 0, -1]) > cylinder(h = 10 + 1, d = diam - 2 + rch); > // reduce the top end > translate([0, 0, height - 10]) > difference() { > cylinder(h = 10 + 1, d = diam + 1); > cylinder(h = 10 + 1, d = diam - 2 - rch); > } > // holes > for (i = [15:5:height-15]) > for (a = [0:15:359]) > translate([0, 0, i]) > rotate([0, 90, a]) > HoleCylinder(); > } > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- "The future is already here. It's just not very evenly distributed" -- William Gibson Me: http://clothbot.com/wiki/ <http://clothbot.com/wiki/>
PF
Peter Falke
Sat, Dec 5, 2015 11:19 PM

There was a discussion some time back: the cutting of a gem did take very
long.
Cutting the individual faces of the gem lead to a lot of overlapping
differences() close to the origin.
Maybe something similar is happening here.
re-odering the differences() lead to faster render times.

2015-12-06 0:05 GMT+01:00 Andrew Plumb andrew@plumb.org:

Consider whether you really need $fn=100 for all those HoleCylinder()
elements. That’s where the bulk of the number-crunching is happening.

Andrew.

On Dec 5, 2015, at 5:43 PM, jon jon@jonbondy.com wrote:

This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6
to complete.  I know that it will, because I did it once before.

How would you speed it up?

Jon

$fn = 100;
rch = 0.1;
height = 200; // 30;
diam = 35;

module HoleCylinder()
cylinder(h = 100, d = diam/10);

difference() {
// outer
cylinder(h = height, d = diam);
// inner
translate([0, 0, -1])
cylinder(h = height + 2, d = diam - 4);
// reduce the bottom end
translate([0, 0, -1])
cylinder(h = 10 + 1, d = diam - 2 + rch);
// reduce the top end
translate([0, 0, height - 10])
difference() {
cylinder(h = 10 + 1, d = diam + 1);
cylinder(h = 10 + 1, d = diam - 2 - rch);
}
// holes
for (i = [15:5:height-15])
for (a = [0:15:359])
translate([0, 0, i])
rotate([0, 90, a])
HoleCylinder();
}


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" --
William Gibson

Me: http://clothbot.com/wiki/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

There was a discussion some time back: the cutting of a gem did take very long. Cutting the individual faces of the gem lead to a lot of overlapping differences() close to the origin. Maybe something similar is happening here. re-odering the differences() lead to faster render times. 2015-12-06 0:05 GMT+01:00 Andrew Plumb <andrew@plumb.org>: > Consider whether you *really* need $fn=100 for all those HoleCylinder() > elements. That’s where the bulk of the number-crunching is happening. > > Andrew. > > On Dec 5, 2015, at 5:43 PM, jon <jon@jonbondy.com> wrote: > > This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6 > to complete. I know that it will, because I did it once before. > > How would you speed it up? > > Jon > > > $fn = 100; > rch = 0.1; > height = 200; // 30; > diam = 35; > > module HoleCylinder() > cylinder(h = 100, d = diam/10); > > difference() { > // outer > cylinder(h = height, d = diam); > // inner > translate([0, 0, -1]) > cylinder(h = height + 2, d = diam - 4); > // reduce the bottom end > translate([0, 0, -1]) > cylinder(h = 10 + 1, d = diam - 2 + rch); > // reduce the top end > translate([0, 0, height - 10]) > difference() { > cylinder(h = 10 + 1, d = diam + 1); > cylinder(h = 10 + 1, d = diam - 2 - rch); > } > // holes > for (i = [15:5:height-15]) > for (a = [0:15:359]) > translate([0, 0, i]) > rotate([0, 90, a]) > HoleCylinder(); > } > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > -- > > "The future is already here. It's just not very evenly distributed" -- > William Gibson > > Me: http://clothbot.com/wiki/ > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
PF
Peter Falke
Sat, Dec 5, 2015 11:32 PM

height = 30; // 30;
diam = 35;

module HoleCylinder()
//    translate([0,0,diam/2-4])#cylinder(h = 8, d = diam/10);
cylinder(h = 100, d = diam/10);

Setting height=30, it takes 1min 22sec to render with the long cylinder.

It takes only 0min 40sec to render with the shorter cylinders.

2015-12-06 0:19 GMT+01:00 Peter Falke stempeldergeschichte@googlemail.com:

There was a discussion some time back: the cutting of a gem did take very
long.
Cutting the individual faces of the gem lead to a lot of overlapping
differences() close to the origin.
Maybe something similar is happening here.
re-odering the differences() lead to faster render times.

2015-12-06 0:05 GMT+01:00 Andrew Plumb andrew@plumb.org:

Consider whether you really need $fn=100 for all those HoleCylinder()
elements. That’s where the bulk of the number-crunching is happening.

Andrew.

On Dec 5, 2015, at 5:43 PM, jon jon@jonbondy.com wrote:

This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6
to complete.  I know that it will, because I did it once before.

How would you speed it up?

Jon

$fn = 100;
rch = 0.1;
height = 200; // 30;
diam = 35;

module HoleCylinder()
cylinder(h = 100, d = diam/10);

difference() {
// outer
cylinder(h = height, d = diam);
// inner
translate([0, 0, -1])
cylinder(h = height + 2, d = diam - 4);
// reduce the bottom end
translate([0, 0, -1])
cylinder(h = 10 + 1, d = diam - 2 + rch);
// reduce the top end
translate([0, 0, height - 10])
difference() {
cylinder(h = 10 + 1, d = diam + 1);
cylinder(h = 10 + 1, d = diam - 2 - rch);
}
// holes
for (i = [15:5:height-15])
for (a = [0:15:359])
translate([0, 0, i])
rotate([0, 90, a])
HoleCylinder();
}


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" --
William Gibson

Me: http://clothbot.com/wiki/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

height = 30; // 30; diam = 35; module HoleCylinder() // translate([0,0,diam/2-4])#cylinder(h = 8, d = diam/10); cylinder(h = 100, d = diam/10); Setting height=30, it takes 1min 22sec to render with the long cylinder. It takes only 0min 40sec to render with the shorter cylinders. 2015-12-06 0:19 GMT+01:00 Peter Falke <stempeldergeschichte@googlemail.com>: > There was a discussion some time back: the cutting of a gem did take very > long. > Cutting the individual faces of the gem lead to a lot of overlapping > differences() close to the origin. > Maybe something similar is happening here. > re-odering the differences() lead to faster render times. > > 2015-12-06 0:05 GMT+01:00 Andrew Plumb <andrew@plumb.org>: > >> Consider whether you *really* need $fn=100 for all those HoleCylinder() >> elements. That’s where the bulk of the number-crunching is happening. >> >> Andrew. >> >> On Dec 5, 2015, at 5:43 PM, jon <jon@jonbondy.com> wrote: >> >> This one will F5 in a few seconds, but it's been 2.5 hours waiting for F6 >> to complete. I know that it will, because I did it once before. >> >> How would you speed it up? >> >> Jon >> >> >> $fn = 100; >> rch = 0.1; >> height = 200; // 30; >> diam = 35; >> >> module HoleCylinder() >> cylinder(h = 100, d = diam/10); >> >> difference() { >> // outer >> cylinder(h = height, d = diam); >> // inner >> translate([0, 0, -1]) >> cylinder(h = height + 2, d = diam - 4); >> // reduce the bottom end >> translate([0, 0, -1]) >> cylinder(h = 10 + 1, d = diam - 2 + rch); >> // reduce the top end >> translate([0, 0, height - 10]) >> difference() { >> cylinder(h = 10 + 1, d = diam + 1); >> cylinder(h = 10 + 1, d = diam - 2 - rch); >> } >> // holes >> for (i = [15:5:height-15]) >> for (a = [0:15:359]) >> translate([0, 0, i]) >> rotate([0, 90, a]) >> HoleCylinder(); >> } >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >> -- >> >> "The future is already here. It's just not very evenly distributed" -- >> William Gibson >> >> Me: http://clothbot.com/wiki/ >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >
J
jon
Sat, Dec 5, 2015 11:35 PM

If I make the cylinder into a module(), then I would not need the
render() would I, except to speed up the F5, which is already quite fast

:)

On 12/5/2015 6:01 PM, Peter Falke wrote:

I would try: make a short cylinder with only one ring of holes, stick
this cylinder in a render(), and add as many of them together as you need.
I would also make the cylinder that punshes the holes as short as
possible, so they will not overlapp.

2015-12-05 23:43 GMT+01:00 jon <jon@jonbondy.com
mailto:jon@jonbondy.com>:

 This one will F5 in a few seconds, but it's been 2.5 hours waiting
 for F6 to complete.  I know that it will, because I did it once
 before.

 How would you speed it up?

 Jon


 $fn = 100;
 rch = 0.1;
 height = 200; // 30;
 diam = 35;

 module HoleCylinder()
     cylinder(h = 100, d = diam/10);

 difference() {
     // outer
     cylinder(h = height, d = diam);
     // inner
     translate([0, 0, -1])
         cylinder(h = height + 2, d = diam - 4);
     // reduce the bottom end
     translate([0, 0, -1])
         cylinder(h = 10 + 1, d = diam - 2 + rch);
     // reduce the top end
     translate([0, 0, height - 10])
         difference() {
             cylinder(h = 10 + 1, d = diam + 1);
             cylinder(h = 10 + 1, d = diam - 2 - rch);
             }
     // holes
     for (i = [15:5:height-15])
         for (a = [0:15:359])
             translate([0, 0, i])
                 rotate([0, 90, a])
                     HoleCylinder();
     }

 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2016.0.7227 / Virus Database: 4477/11118 - Release Date: 12/05/15

If I make the cylinder into a module(), then I would not need the render() would I, except to speed up the F5, which is already quite fast :) On 12/5/2015 6:01 PM, Peter Falke wrote: > I would try: make a short cylinder with only one ring of holes, stick > this cylinder in a render(), and add as many of them together as you need. > I would also make the cylinder that punshes the holes as short as > possible, so they will not overlapp. > > > > 2015-12-05 23:43 GMT+01:00 jon <jon@jonbondy.com > <mailto:jon@jonbondy.com>>: > > This one will F5 in a few seconds, but it's been 2.5 hours waiting > for F6 to complete. I know that it will, because I did it once > before. > > How would you speed it up? > > Jon > > > $fn = 100; > rch = 0.1; > height = 200; // 30; > diam = 35; > > module HoleCylinder() > cylinder(h = 100, d = diam/10); > > difference() { > // outer > cylinder(h = height, d = diam); > // inner > translate([0, 0, -1]) > cylinder(h = height + 2, d = diam - 4); > // reduce the bottom end > translate([0, 0, -1]) > cylinder(h = 10 + 1, d = diam - 2 + rch); > // reduce the top end > translate([0, 0, height - 10]) > difference() { > cylinder(h = 10 + 1, d = diam + 1); > cylinder(h = 10 + 1, d = diam - 2 - rch); > } > // holes > for (i = [15:5:height-15]) > for (a = [0:15:359]) > translate([0, 0, i]) > rotate([0, 90, a]) > HoleCylinder(); > } > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > No virus found in this message. > Checked by AVG - www.avg.com <http://www.avg.com> > Version: 2016.0.7227 / Virus Database: 4477/11118 - Release Date: 12/05/15 >
T
Trygon
Sun, Dec 6, 2015 10:09 AM

I agree with clothbot, $fn=100 appears a little excessive!

I have generally stopped using $fn, $fs & $fa since it can be hard to
determine sensible values to use and falling back to a large value for $fn
is tempting and works but is slow. I use $fe (see
http://forum.openscad.org/fe-Tolerance-based-arc-approximation-tp14212p14933.html)
and would code as below.

Cheers,
Trygon

$fn = undef;
$fs=0.01; // very small => $fa used

$fe=0.1; // 0.1/4 for final output?

rch = 0.1;
height = 200; // 30;
diam = 35;

function fa(r)=$fn>0?360/($fn>3?$fn:3):
$fe>0?$fe<r?min(45,2acos(1-$fe/r)):45:
360/max(min(360/($fa>0.01?$fa:0.01),
2
PI*r/($fs>0.01?$fs:0.01)),5);

module HoleCylinder()
cylinder(h = 100, d = diam/10, $fa=fa(diam/20));

difference() {
// outer
cylinder(h = height, d = diam, $fa=fa(diam/2));
// inner
translate([0, 0, -1])
cylinder(h = height + 2, d = diam - 4, $fa=fa((diam-4)/2));
// reduce the bottom end
translate([0, 0, -1])
cylinder(h = 10 + 1, d = diam - 2 + rch, $fa=fa((diam-2+rch)/2));
// reduce the top end
translate([0, 0, height - 10])
difference() {
cylinder(h = 10 + 1, d = diam + 1, $fa=fa((diam+1)/2));
cylinder(h = 10 + 1, d = diam - 2 - rch,
$fa=fa((diam-2-rch)/2));
}
// holes
for (i = [15:5:height-15])
for (a = [0:15:359])
translate([0, 0, i])
rotate([0, 90, a])
HoleCylinder();
}

--
View this message in context: http://forum.openscad.org/here-s-an-interesting-one-to-speed-optimize-tp14966p14977.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I agree with clothbot, $fn=100 appears a little excessive! I have generally stopped using $fn, $fs & $fa since it can be hard to determine sensible values to use and falling back to a large value for $fn is tempting and works but is slow. I use $fe (see http://forum.openscad.org/fe-Tolerance-based-arc-approximation-tp14212p14933.html) and would code as below. Cheers, Trygon $fn = undef; $fs=0.01; // very small => $fa used $fe=0.1; // 0.1/4 for final output? rch = 0.1; height = 200; // 30; diam = 35; function fa(r)=$fn>0?360/($fn>3?$fn:3): $fe>0?$fe<r?min(45,2*acos(1-$fe/r)):45: 360/max(min(360/($fa>0.01?$fa:0.01), 2*PI*r/($fs>0.01?$fs:0.01)),5); module HoleCylinder() cylinder(h = 100, d = diam/10, $fa=fa(diam/20)); difference() { // outer cylinder(h = height, d = diam, $fa=fa(diam/2)); // inner translate([0, 0, -1]) cylinder(h = height + 2, d = diam - 4, $fa=fa((diam-4)/2)); // reduce the bottom end translate([0, 0, -1]) cylinder(h = 10 + 1, d = diam - 2 + rch, $fa=fa((diam-2+rch)/2)); // reduce the top end translate([0, 0, height - 10]) difference() { cylinder(h = 10 + 1, d = diam + 1, $fa=fa((diam+1)/2)); cylinder(h = 10 + 1, d = diam - 2 - rch, $fa=fa((diam-2-rch)/2)); } // holes for (i = [15:5:height-15]) for (a = [0:15:359]) translate([0, 0, i]) rotate([0, 90, a]) HoleCylinder(); } -- View this message in context: http://forum.openscad.org/here-s-an-interesting-one-to-speed-optimize-tp14966p14977.html Sent from the OpenSCAD mailing list archive at Nabble.com.
PF
Peter Falke
Sun, Dec 6, 2015 4:25 PM

Your code renders in  2 hours, 4 minutes, 48 seconds on my machine.

With the shorter cylinders, that dont overlap at the origion it is faster:
//    translate([0,0,diam/2-4])#cylinder(h = 8, d = diam/10);

It renders in 0 hours, 42 minutes, 29 seconds

2015-12-06 11:09 GMT+01:00 Trygon db5765@outlook.com:

I agree with clothbot, $fn=100 appears a little excessive!

I have generally stopped using $fn, $fs & $fa since it can be hard to
determine sensible values to use and falling back to a large value for $fn
is tempting and works but is slow. I use $fe (see

http://forum.openscad.org/fe-Tolerance-based-arc-approximation-tp14212p14933.html
)
and would code as below.

Cheers,
Trygon

$fn = undef;
$fs=0.01; // very small => $fa used

$fe=0.1; // 0.1/4 for final output?

rch = 0.1;
height = 200; // 30;
diam = 35;

function fa(r)=$fn>0?360/($fn>3?$fn:3):
$fe>0?$fe<r?min(45,2acos(1-$fe/r)):45:
360/max(min(360/($fa>0.01?$fa:0.01),
2
PI*r/($fs>0.01?$fs:0.01)),5);

module HoleCylinder()
cylinder(h = 100, d = diam/10, $fa=fa(diam/20));

difference() {
// outer
cylinder(h = height, d = diam, $fa=fa(diam/2));
// inner
translate([0, 0, -1])
cylinder(h = height + 2, d = diam - 4, $fa=fa((diam-4)/2));
// reduce the bottom end
translate([0, 0, -1])
cylinder(h = 10 + 1, d = diam - 2 + rch, $fa=fa((diam-2+rch)/2));
// reduce the top end
translate([0, 0, height - 10])
difference() {
cylinder(h = 10 + 1, d = diam + 1, $fa=fa((diam+1)/2));
cylinder(h = 10 + 1, d = diam - 2 - rch,
$fa=fa((diam-2-rch)/2));
}
// holes
for (i = [15:5:height-15])
for (a = [0:15:359])
translate([0, 0, i])
rotate([0, 90, a])
HoleCylinder();
}

--
View this message in context:
http://forum.openscad.org/here-s-an-interesting-one-to-speed-optimize-tp14966p14977.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Your code renders in 2 hours, 4 minutes, 48 seconds on my machine. With the shorter cylinders, that dont overlap at the origion it is faster: // translate([0,0,diam/2-4])#cylinder(h = 8, d = diam/10); It renders in 0 hours, 42 minutes, 29 seconds 2015-12-06 11:09 GMT+01:00 Trygon <db5765@outlook.com>: > I agree with clothbot, $fn=100 appears a little excessive! > > I have generally stopped using $fn, $fs & $fa since it can be hard to > determine sensible values to use and falling back to a large value for $fn > is tempting and works but is slow. I use $fe (see > > http://forum.openscad.org/fe-Tolerance-based-arc-approximation-tp14212p14933.html > ) > and would code as below. > > Cheers, > Trygon > > > $fn = undef; > $fs=0.01; // very small => $fa used > > $fe=0.1; // 0.1/4 for final output? > > rch = 0.1; > height = 200; // 30; > diam = 35; > > function fa(r)=$fn>0?360/($fn>3?$fn:3): > $fe>0?$fe<r?min(45,2*acos(1-$fe/r)):45: > 360/max(min(360/($fa>0.01?$fa:0.01), > 2*PI*r/($fs>0.01?$fs:0.01)),5); > > module HoleCylinder() > cylinder(h = 100, d = diam/10, $fa=fa(diam/20)); > > difference() { > // outer > cylinder(h = height, d = diam, $fa=fa(diam/2)); > // inner > translate([0, 0, -1]) > cylinder(h = height + 2, d = diam - 4, $fa=fa((diam-4)/2)); > // reduce the bottom end > translate([0, 0, -1]) > cylinder(h = 10 + 1, d = diam - 2 + rch, $fa=fa((diam-2+rch)/2)); > // reduce the top end > translate([0, 0, height - 10]) > difference() { > cylinder(h = 10 + 1, d = diam + 1, $fa=fa((diam+1)/2)); > cylinder(h = 10 + 1, d = diam - 2 - rch, > $fa=fa((diam-2-rch)/2)); > } > // holes > for (i = [15:5:height-15]) > for (a = [0:15:359]) > translate([0, 0, i]) > rotate([0, 90, a]) > HoleCylinder(); > } > > > > > -- > View this message in context: > http://forum.openscad.org/here-s-an-interesting-one-to-speed-optimize-tp14966p14977.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
T
Trygon
Sun, Dec 6, 2015 8:49 PM

Peter,

I assume that your comment, "Your code renders in  2 hours, 4 minutes, 48
seconds on my machine.", was not with regard to the modified code I
provided?  The modified code with $fe=0.1 renders in 6 minutes, 21 seconds
on my PC.

Trygon

--
View this message in context: http://forum.openscad.org/here-s-an-interesting-one-to-speed-optimize-tp14966p14985.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Peter, I assume that your comment, "Your code renders in 2 hours, 4 minutes, 48 seconds on my machine.", was not with regard to the modified code I provided? The modified code with $fe=0.1 renders in 6 minutes, 21 seconds on my PC. Trygon -- View this message in context: http://forum.openscad.org/here-s-an-interesting-one-to-speed-optimize-tp14966p14985.html Sent from the OpenSCAD mailing list archive at Nabble.com.
PF
Peter Falke
Sun, Dec 6, 2015 8:57 PM

I asumed jon had a reason for choosing fn=100.

2015-12-06 21:49 GMT+01:00 Trygon db5765@outlook.com:

Peter,

I assume that your comment, "Your code renders in  2 hours, 4 minutes, 48
seconds on my machine.", was not with regard to the modified code I
provided?  The modified code with $fe=0.1 renders in 6 minutes, 21 seconds
on my PC.

Trygon

--
View this message in context:
http://forum.openscad.org/here-s-an-interesting-one-to-speed-optimize-tp14966p14985.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I asumed jon had a reason for choosing fn=100. 2015-12-06 21:49 GMT+01:00 Trygon <db5765@outlook.com>: > Peter, > > I assume that your comment, "Your code renders in 2 hours, 4 minutes, 48 > seconds on my machine.", was not with regard to the modified code I > provided? The modified code with $fe=0.1 renders in 6 minutes, 21 seconds > on my PC. > > Trygon > > > > > -- > View this message in context: > http://forum.openscad.org/here-s-an-interesting-one-to-speed-optimize-tp14966p14985.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >