Quantcast

trouble making a round flange with holes in

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

trouble making a round flange with holes in

Tanker3
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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Ronaldo
It is impossible to identify a syntax error without seeing the code.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Tanker3
In reply to this post by Tanker3
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.  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Ronaldo
Remove the second brace after children() and try.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Ian Nichols
In reply to this post by Tanker3

On 21 March 2017 at 07:32, Tanker3 <[hidden email]> 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
[hidden email]
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);

<put code for ring of cylinders to be subtracted in here>

}
}

Ian
--
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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Tanker3
In reply to this post by Ronaldo
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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Tanker3
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!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Ronaldo
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 ();
    }
}
 

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Parkinbot
Btw, this is a very useful operator, which I use everyday. In my shortcuts library I implemented it like this:

module rotN(r=10, N=4, offs=0, M=undef) for(i=[0:(M?M-1:N-1)])  rotate([0,0,offs+i*360/N])  translate([r,0,0]) children();
 
// Examples
color("green") rotN(40,12) cylinder(r=4, h=10);  
color("red") rotN(30,12,M=6) cylinder(r=4, h=10);  
color("blue") rotN(20,12,120, 6) cylinder(r=4, h=10);  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

doug.moen
Cool. My version is called `rep_rotate(count) shape` (rep == repeat).

module rep_rotate(count)
    for (i=[0:count-1])
        rotate(i*360/count)
            children();

color("green")
  rep_rotate(12) translate([40,0,0]) cylinder(r=4, h=10);

I'm not saying this is a better interface, I just think it's interesting that a lot of people have come up with the same abstraction, and I like to see how other people use OpenSCAD. Now that I've seen these other modules, I might add a radius to mine.

On 22 March 2017 at 12:25, Parkinbot <[hidden email]> wrote:
Btw, this is a very useful operator, which I use everyday. In my shortcuts
library I implemented it like this:


> module rotN(r=10, N=4, offs=0, M=undef) for(i=[0:(M?M-1:N-1)])
> rotate([0,0,offs+i*360/N])  translate([r,0,0]) children();
>
> // Examples
> color("green") rotN(40,12) cylinder(r=4, h=10);
> color("red") rotN(30,12,M=6) cylinder(r=4, h=10);
> color("blue") rotN(20,12,120, 6) cylinder(r=4, h=10);





--
View this message in context: http://forum.openscad.org/trouble-making-a-round-flange-with-holes-in-tp20961p20992.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Ronaldo
In reply to this post by Parkinbot
Parkinbot wrote
Btw, this is a very useful operator, which I use everyday. In my shortcuts library I implemented it like this:
Nice. My trouble with that kind of function and operators is that the more flexible they are the more parameter names I have to memorize when I need them. Yes, I always may consult the code but that is their burden.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Parkinbot
Ronaldo wrote
Nice. My trouble with that kind of function and operators is that the more flexible they are the more parameter names I have to memorize when I need them. Yes, I always may consult the code but that is their burden.
That is why I implement a help() module in every library. For shortcuts.scad you get the output:
ECHO: "
shortcuts.scad
help(): shows this help
help_shortcuts(): shows this help
show_examples(): shows some examples
place_in_rect(): places children objects in grid
Transformations:
transform : T(x=0, y=0, z=0), Tx(x=0) , Ty(y=0), Tz(z=0)
rotate : R(x=0, y=0, z=0), Rx(x=0) , Ry(y=0), Rz(z=0)
scale : S(x=1, y=1, z=1), Sx(x=1) , Sy(y=1), Sz(z=1)
Logical
difference : D()
union : U()
intersection : I()
Useful
N instances around circle : rotN(r=10, N=4, offs=0, M=undef)
range function [0:1:N] : Rg(N)
color : C(r,b,g,t) or C(string,t)
Primitives
circle : Ci(r=10, d=undef)
circle_half : CiH(r=10, w=0, d=undef)
circle_segment : CiS(r=10, w1=0, w2=90, d=undef)
square : Sq(x=10, y=undef, center=true))
cylinder : Cy(r=10, h=1, center=true, r1=undef, r2=undef, d=undef)
cylinder_half : CyH(r=10, w=0, d=undef)
cylinder_segment: CyS(r=10, h=1, w1=0, w2=90,center=true, d=undef)
cylinder_segment: Pie(r=10, h=1, w1=0, w2=90,center=true, d=undef)
cube : Cu(x=10, y=undef, z=undef, center=true)
ring : Ri(R=10, r=5, h=1, center=true, D=undef, d=undef)
ring_half : RiH(R=10, r=5, h=1, w=0 center=true, D=undef, d=undef)
ring_segment : RiS(R=10, r=5, h=1, w1=0, w2=90, center=true, D=undef, d=undef)
sphere: Sp(r=10))
sphere_half: SpH(r=10, w1 = 0, w2 = 0)
torus: To(torus(R=10, r=1, w1=0, w2=360)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Ronaldo
2017-03-22 19:24 GMT-03:00 Parkinbot <[hidden email]>:
That is why I implement a help() module in every library. For shortcuts.scad
you get the output:

That is a good practice but what do you do when you have several libraries in <use>, each with its help() ? There is no way to qualify an used function or module.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: trouble making a round flange with holes in

Parkinbot
Ronaldo wrote
That is a good practice but what do you do when you have several libraries
in <use>, each with its help() ? There is no way to qualify an used
function or module.
1. There is a help_library() synonym (another naming convention)
2. You always can include the library you want to call help() latest (yet another hack, I know)
Loading...