Welcome! Log In Create A New Profile

Advanced

Ok, another Openscad question...

Posted by Tekwizard 
Ok, another Openscad question...
April 24, 2013 01:57PM
First of all, thanks for the help I've been getting with Openscad. I'm trying to learn it because I believe it is the way to go, but of course the manual isn't self explanitory, at least not to me.

I am trying to design a horizontal windmill, of sorts (try the code below). I am lining up the cylinders to subtract by eye on my computer and I know that can't be a very accurate way of placing them, and will cause stabiliy and/or vibrational problems. Is there a way to create arrays in Openscad that would place the cylinders accurately around the pivot point?

One other question, and this might be hard, is there anyway to trim off the back end of the blades to make them thinner, but following the same curve as the front side? I'd love to make them more like sails than just blocky impellers...

Here is what I've managed so far, but I'm sure I'm doing it inefficiently:



$fn=100;

difference() {


cylinder(h = 100, r=90);

cylinder(h = 210, r=15, center = true);


//Blades

translate([60,13,-2])
cylinder(h = 104, r=30);

translate([35,-50,-2])
cylinder(h = 104, r=30);

translate([20,70,-2])
cylinder(h = 104, r=30);

translate([60,13,-2])
cylinder(h = 104, r=30);

translate([60,13,-2])
cylinder(h = 104, r=30);

}

Did I get the indenting right Bob?

Thanks,
Jon
Re: Ok, another Openscad question...
April 24, 2013 02:47PM
Impossible to tell if you got the indentation right. Wrap your code in code tags if you want to preserve spaces, otherwise all text is formatted as text, losing the indentation.

For the first part of your question, you want the For statment.

$fn=100; 

difference() { 
	cylinder(h = 100, r=90); 
	cylinder(h = 210, r=15, center = true); 

//Blades 
	for (b = [0:5]) {
    		rotate([0,0,b*360/6])
		translate([65,0,-1])
    		cylinder(h=104,r=30);
	}

}

Here, the for (b = [0:5]) executes the contained code six times, with the b variable set to 0,1,2,3,4 and 5. The rotation is calculated from b, if you change the size of the for range then change the size of the divisor to match. The rest is simple stuff.

No idea on the second part of the question, a drawing would be helpful.

Edited 1 time(s). Last edit at 04/24/2013 02:53PM by Andrew Smith.
Re: Ok, another Openscad question...
April 24, 2013 10:44PM
Andrew Smith Wrote:
-------------------------------------------------------
> Impossible to tell if you got the indentation
> right. Wrap your code in code tags if you want to
> preserve spaces, otherwise all text is formatted
> as text, losing the indentation.
>
> For the first part of your question, you want the
> For statment.
>
>
> $fn=100;
>
> difference() {
> cylinder(h = 100, r=90);
> cylinder(h = 210, r=15, center = true);
>
> //Blades
> for (b = [0:5]) {
> rotate([0,0,b*360/6])
> translate([65,0,-1])
> cylinder(h=104,r=30);
> }
>
> }
>
>
> Here, the for (b = [0:5]) executes the contained
> code six times, with the b variable set to
> 0,1,2,3,4 and 5. The rotation is calculated from
> b, if you change the size of the for range then
> change the size of the divisor to match. The rest
> is simple stuff.
>
> No idea on the second part of the question, a
> drawing would be helpful.

Wow, you really are a lot of help Andrew smiling smiley

I can't say that I understand how this works yet, but I will certainly study it further so that I understand this gift of knowledge from you.

I will "hack out the second half of the question using cubes on one of the vanes so that you can see roughly what I'm trying to do. I think it is probably hard to do because I'd need to subtract reverse cylinders. Maybe not the best description, but I'll try and change the code so that you can see better.

Thanks,
Jon
Re: Ok, another Openscad question...
April 24, 2013 11:12PM
Here is the code that I created to show roughly how the blades are meant to look. (One blade is made to look like I'm after). Obviously the thing would be horribly unbalanced if I tried to just chop away pieces and eyeball where to translate them to. I used three cubes to try and smooth the back side of the blade a bit, but of course I'd like to make it very smooth. Would I use the "for"statement here too? If so, what shape would I be using to remove the unwanted material on the back of the blades?

I don't know what code tags are or how to wrap my code in them.


$fn=100;

difference() {
cylinder(h = 100, r=90);
cylinder(h = 210, r=15, center = true);



//Blades
for (b = [0:5]) {
rotate([0,0,b*360/6])
translate([65,0,-1])
cylinder(h=104,r=30);
}


translate([65,15,-10])
cube (size = [30,50,120]);

translate([49,25,-10])
rotate([0,0,-45])
cube (size = [30,50,120]);


translate([49,20,-10])
rotate([0,0,-30])
cube (size = [30,50,120]);


}
Re: Ok, another Openscad question...
April 25, 2013 01:07AM
I know by the past month how openscad is a learning curve, but I stumbled across freecad.
Since using freecad it easier design parts for me, for instance im designing a new extruder, and being able to import stl
s I can put all the parts together too see if they fit.
Re: Ok, another Openscad question...
April 25, 2013 03:19AM
You can import STL files in OpenSCAD too.


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: Ok, another Openscad question...
April 25, 2013 05:22AM
To use code tags, simply wrap your code in [ code ] and [ /code ] , without the spaces. The result is:

$fn=100;

blades = 6;
blade_inner_radius = 30;
blade_outer_radius= 33;

difference(){
	intersection(){
		cylinder(h=100,r=90,center=true);
		difference(){
			union(){
				cylinder(h=100,r=60,center=true);
				for (b= [0:blades-1]){
					rotate([0,0,b*360/blades])
					translate([65,0,0])
					cylinder(r=blade_outer_radius, h = 100, center = true);
				}
			}
			for (b= [0:blades-1]){
				rotate([0,0,b*360/blades])
				translate([75,10,0])
			cylinder(r=blade_inner_radius, h = 102, center = true);
			}
		}

	}
	cylinder(h=110,r=15,center=true);
}
Re: Ok, another Openscad question...
April 26, 2013 01:24AM
Andrew Smith Wrote:
-------------------------------------------------------
> To use code tags, simply wrap your code in [ code
> ] and [ /code ] , without the spaces. The result
> is:
>
>
> $fn=100;
>
> blades = 6;
> blade_inner_radius = 30;
> blade_outer_radius= 33;
>
> difference(){
> intersection(){
> cylinder(h=100,r=90,center=true);
> difference(){
> union(){
> cylinder(h=100,r=60,center=true);
> for (b= [0:blades-1]){
> rotate([0,0,b*360/blades])
> translate([65,0,0])
> cylinder(r=blade_outer_radius, h = 100,
> center = true);
> }
> }
> for (b= [0:blades-1]){
> rotate([0,0,b*360/blades])
> translate([75,10,0])
> cylinder(r=blade_inner_radius, h = 102, center
> = true);
> }
> }
>
> }
> cylinder(h=110,r=15,center=true);
> }

This is excellent Andrew, thank you so much! I will be studying this for some time as I work to understand how you put it together, but it will be worth the effort.
I need to make the blades thinner and lighter, but now that I know how to code it, I'm sure I can figure out what to change in the numbers.

I still don't get the wrapping the code part though. Do you mean that when I cut and paste it here that I should put a [ at the beginning and a ] at the end of the whole thing? Or should I be doing that for every line?

Thanks,
Jon
Re: Ok, another Openscad question...
April 26, 2013 05:35AM
Hi Andrew,

If you're interested, here is the final design of the impeller for my horizontal windmill...


[

$fn=200;

blades = 6;
blade_inner_radius = 32;
blade_outer_radius= 33;

difference(){
intersection(){
cylinder(h=100,r=98,center=true);
difference(){
union(){

cylinder(h=100,r=38,center=true);
for (b= [0:blades-1]){
rotate([0,0,b*360/blades])
translate([65,0,0])
cylinder(r=blade_outer_radius, h = 100, center = true);


}
}

for (b= [0:blades-1]){
rotate([0,0,b*360/blades])
translate([66,1.7,0])
cylinder(r=blade_inner_radius, h = 102, center = true);

}

for (b= [0:blades-1])
rotate([0,0,b*360/blades])
translate([22,0,0])
cylinder(r=10, h = 110, center = true);


for (b= [0:blades-1])
rotate([0,0,b*360/blades])
translate([27,16,0])
cylinder(r=5, h = 110, center = true);

}

}
cylinder(h=110,r=10,center=true, $fn=6);
}

]
Re: Ok, another Openscad question...
April 26, 2013 05:38AM
As you can see, I tried wrapping the code the these [ ] and nothing happened. What am I not understanding?
Re: Ok, another Openscad question...
April 26, 2013 05:50AM
Mark the CODE (select it) and then press the CODE button (third from the right in the TOOLBAR).

$fn=200;

blades = 6;
blade_inner_radius = 32;
blade_outer_radius= 33;

difference(){
	intersection(){
		cylinder(h=100,r=98,center=true);
		difference(){
			union(){
				cylinder(h=100,r=38,center=true);
				for (b= [0:blades-1]){
					rotate([0,0,b*360/blades])
					translate([65,0,0])
					cylinder(r=blade_outer_radius, h = 100, center = true);
				}
			}

			for (b= [0:blades-1]){
				rotate([0,0,b*360/blades])
				translate([66,1.7,0])
				cylinder(r=blade_inner_radius, h = 102, center = true);
			}

			for (b= [0:blades-1])
				rotate([0,0,b*360/blades])
					translate([22,0,0])
						cylinder(r=10, h = 110, center = true);

			for (b= [0:blades-1])
				rotate([0,0,b*360/blades])
					translate([27,16,0])
						cylinder(r=5, h = 110, center = true);
		}
	}
	cylinder(h=110,r=10,center=true, $fn=6);
}

BTW, looks very nice:




Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Attachments:
open | download - blade.png (39.1 KB)
Re: Ok, another Openscad question...
April 27, 2013 04:53AM
Thanks Bob, I get it now. It's the button that says "formatted code".
I was looking for something I had to do in Openscad.
I'm going to try and print the impeller tomorrow and it should take all day. If it turns out ok, I'll post a photo of it.

Jon
Sorry, only registered users may post in this forum.

Click here to login