I am very new to Open SCAD and I am trying to produce a part for a model I am
making.This is a drive wheel with a series of holes round its periphery, at
equal spacing. I have followed the 'difference' method to produce the
central axle hole, no problem there, and have used the 'children' method to
produce small cylinders, at the desired positions around the periphery. Now
I dont seem to be able to use the 'difference' method to make these holes
instead of cylinders. Seems whatever I try I come up with syntax error.
Probably a bit thick but would appreciate some guidance.
--
View this message in context: http://forum.openscad.org/trouble-making-a-round-flange-with-holes-in-tp20961.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
It is impossible to identify a syntax error without seeing the code.
Many apologies.
The code I have been trying to use is:
make_ring_of (radius = 40, count = 12)
cylinder (r = 4, h = 10, centre = true);
module make_ring_of (radius, count)
{
for (a = [0: count -1]){
angle = a * 360 /count;
translate (radius * [sin(angle), -cos(angle), 0])
rotate ([0, 0, angle])
children ();
}
}
translate ([0,0,2]){
difference (){
cylinder (h=5, r=50);
cylinder (h=10, r=5);
}
}
This gives me the disc with a central hole of 10mm diameter with a ring of
cylinders at 40 mm radius. This I am happy with, but then, when I try to
include the code for making the ring of cylinders in to the difference part
of the code in order to remove the ring of cylinders and replace them with
holes it won't work.
I am very new to using code and feel that I must have missed something
fundamental.
--
View this message in context: http://forum.openscad.org/trouble-making-a-round-flange-with-holes-in-tp20961p20972.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Remove the second brace after children() and try.
On 21 March 2017 at 07:32, Tanker3 josieandpaul1@hotmail.co.uk wrote:
Many apologies.
The code I have been trying to use is:
make_ring_of (radius = 40, count = 12)
cylinder (r = 4, h = 10, centre = true);
module make_ring_of (radius, count)
{
for (a = [0: count -1]){
angle = a * 360 /count;
translate (radius * [sin(angle), -cos(angle), 0])
rotate ([0, 0, angle])
children ();
}
}
translate ([0,0,2]){
difference (){
cylinder (h=5, r=50);
cylinder (h=10, r=5);
}
}
This gives me the disc with a central hole of 10mm diameter with a ring of
cylinders at 40 mm radius. This I am happy with, but then, when I try to
include the code for making the ring of cylinders in to the difference part
of the code in order to remove the ring of cylinders and replace them with
holes it won't work.
I am very new to using code and feel that I must have missed something
fundamental.
--
View this message in context: http://forum.openscad.org/
trouble-making-a-round-flange-with-holes-in-tp20961p20972.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
You've put the code to generate the ring of cylinders in the wrong place,
as far as I can see. Difference () will subtract, from the first object in
its list, all the other objects in the list.
This should do it, when expanded with the necessary code:
translate ([0,0,2]){
difference (){
cylinder (h=5, r=50);
cylinder (h=10, r=5);
}
}
Stand firm for what you believe in, until and unless logic and experience
prove you wrong. Remember: when the emperor looks naked, the emperor is
naked, the truth and a lie are not "sort-of the same thing" and there is
no aspect, no facet, no moment of life that can't be improved with pizza.
-Daria Morgendorffer
I tried what you suggested with no luck. I still come up with parser error
between 'module' and 'make_ring_of'. I've also tried moving the code for the
ring of cylinders into the code for difference() and still no luck. Maybe
I'm trying to do it the wrong way.
--
View this message in context: http://forum.openscad.org/trouble-making-a-round-flange-with-holes-in-tp20961p20982.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
This works:
module make_ring_of (radius, count)
{
for (a = [0: count -1]){
angle = a * 360 /count;
translate (radius * [sin(angle), -cos(angle), 0])
rotate ([0, 0, angle])
children ();
}
}
translate ([0,0,2]){
difference (){
cylinder (h=5, r=50);
translate([0, 0, -1]) {
cylinder (h=10, r=5);
make_ring_of (radius = 40, count = 12)
cylinder (r = 4, h = 10, centre = true);
}
}
}
On 21 March 2017 at 13:39, Tanker3 josieandpaul1@hotmail.co.uk wrote:
I tried what you suggested with no luck. I still come up with parser error
between 'module' and 'make_ring_of'. I've also tried moving the code for
the
ring of cylinders into the code for difference() and still no luck. Maybe
I'm trying to do it the wrong way.
--
View this message in context: http://forum.openscad.org/
trouble-making-a-round-flange-with-holes-in-tp20961p20982.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
Many thanks! Had to amend slightly as holes didn't go right through. Last
line:
cylinder (r=4, h=13, center=true);.
Can move on now!
--
View this message in context: http://forum.openscad.org/trouble-making-a-round-flange-with-holes-in-tp20961p20988.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
They go all the way through on the code I posted but centre is the wrong
spelling, so yes if you correct that they would need to be longer and you
can get rid of the translate -1.
This is how I would do it:
thickness = 5;
translate ([0,0,2]){
difference (){
cylinder (h = thickness, r = 50);
cylinder (h = 2 * thickness + 1, r = 5, center = true);
make_ring_of (radius = 40, count = 12)
cylinder (r = 4, h = 2 * thickness + 1, center = true);
}
}
On 22 March 2017 at 07:51, Tanker3 josieandpaul1@hotmail.co.uk wrote:
Many thanks! Had to amend slightly as holes didn't go right through. Last
line:
cylinder (r=4, h=13, center=true);.
Can move on now!
--
View this message in context: http://forum.openscad.org/
trouble-making-a-round-flange-with-holes-in-tp20961p20988.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
A small detail: in the module make_ring_of(), things gets more readable if
all the trigs are avoided:
module make_ring_of (radius, count)
{
for (a = [0: count -1]){
angle = a * 360 /count;
rotate(angle)
translate([0,-radius,0])
children ();
}
}