discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Rotating a cylinder along its own axis

GH
gene heskett
Tue, Jul 18, 2023 8:25 PM

On 7/18/23 12:29, jpm2nice-tech--- via Discuss wrote:

Am I doing wrong? Which alternate solution is possible?
cylinder(h=3,d1=3,d2=4,center=true,$fn=4);
Thanks for any idea on this.

A new bee. Somebody that wants to learn.  So am I  ;o)>

You can stack operations as a single statement, terminated by a ;

An expanded example:

'#translate([0,0,15])rotate([0,0,45])cylinder(h=6,d1=6,d2=8,center=true,$fn=4);'

Then reading that statement right to left:

'cylinder(h=var,d1=var,d2=var,center=true|false);' draws your shape, can
be a call to another "module"

The resultant square will be the chord of a square with its 4 points
touching the circle of diameter in d|d1|d2.

'rotate([0,0,45])' squares it up so the dimensions are the x,y,z by
rotation of the z axis in this case.

'translate([0,0,15])' then moves that to wherever you need it in 3d space.

the leading # sign then makes it visible for an F5 if inside a
difference() statement but outside of the 'scope' of the first line(s)
of a 'difference()' statment.

You can do this:

module partname()
{
difference()
(
union()
{
statements to draw a complex part
} // end of union() now sub cutouts
statements to subtract things, like bolt holes etc
} // end of difference()
}// end of module
partname(); // actually executes the module.

and you can preface that partname(); with its own location/orientation
stuff. I don't like how Cura occasionally mucks up adjusting a parts
location on the printer bed, so I usually locate the part on the bed in
openscad,

There is a cheat sheet that shows all that in the help pulldown. Pretty
clear once you know the shorthand notation used. It can be obtuse.

OpenSCAD is pile of primitives and libraries by the other folks on this
list, that can actually do very complex stuff.

And there are people here that can do much more complex stuff than I
have so far. I'm not exactly a new bee but I am getting comfortable with
it.  And I'm looking at my 89th birthday in about 3 months.

Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

On 7/18/23 12:29, jpm2nice-tech--- via Discuss wrote: >Am I doing wrong? Which alternate solution is possible? > `cylinder(h=3,d1=3,d2=4,center=true,$fn=4);` >Thanks for any idea on this. A new bee. Somebody that wants to learn. So am I ;o)> You can stack operations as a single statement, terminated by a ; An expanded example: '#translate([0,0,15])rotate([0,0,45])cylinder(h=6,d1=6,d2=8,center=true,$fn=4);' Then reading that statement right to left: 'cylinder(h=var,d1=var,d2=var,center=true|false);' draws your shape, can be a call to another "module" The resultant square will be the chord of a square with its 4 points touching the circle of diameter in d|d1|d2. 'rotate([0,0,45])' squares it up so the dimensions are the x,y,z by rotation of the z axis in this case. 'translate([0,0,15])' then moves that to wherever you need it in 3d space. the leading # sign then makes it visible for an F5 if inside a difference() statement but outside of the 'scope' of the first line(s) of a 'difference()' statment. You can do this: module partname() { difference() ( union() { statements to draw a complex part } // end of union() now sub cutouts statements to subtract things, like bolt holes etc } // end of difference() }// end of module partname(); // actually executes the module. and you can preface that partname(); with its own location/orientation stuff. I don't like how Cura occasionally mucks up adjusting a parts location on the printer bed, so I usually locate the part on the bed in openscad, There is a cheat sheet that shows all that in the help pulldown. Pretty clear once you know the shorthand notation used. It can be obtuse. OpenSCAD is pile of primitives and libraries by the other folks on this list, that can actually do very complex stuff. And there are people here that can do much more complex stuff than I have so far. I'm not exactly a new bee but I am getting comfortable with it. And I'm looking at my 89th birthday in about 3 months. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page <http://geneslinuxbox.net:6309/>
JT
jpm2nice-tech@yahoo.fr
Thu, Jul 20, 2023 9:01 AM

Thanks, Gene, but its exactly what I was doing.


Finally, to obtain what I wanted, I had to write TWO consecutive rotates:
rotate ([0,90,0]) rotate([0,0,45]) cylinder(h=1,d1=3,d2=4, center=true,$fn=4)
I dont understand why...

(Something else I dont understand is when I “reply to the list” from my mailer, it sometimes works, and sometimes not.)


Regards

Thanks, Gene, but its exactly what I was doing. \ Finally, to obtain what I wanted, I had to write TWO consecutive rotates: \ rotate (\[0,90,0\]) rotate(\[0,0,45\]) cylinder(h=1,d1=3,d2=4, center=true,$fn=4) \ I dont understand why... (Something else I dont understand is when I “reply to the list” from my mailer, it sometimes works, and sometimes not.) \ Regards