The convention for machines is that shafts rotate on the z-axis. That’s fine in OpenSCAD if the machine is a milling machine or a helicopter, but tricky if the shaft(s) is/are horizontal, as the only way to rotate the object in the viewport around its vertical axis only is by adjusting y in $vpr([x,y,z]);. If you try to use the cursor, which would be more convenient, the object goes every which way. Can OpenSCAD be set up to rotate a machine/engine about its vertical y-axis, keeping the view from above, using the cursor?
Example: shaft with gear
$vpr=([-35, 45, 0]); // Isometric view, x=-35 for view from above, y=45+90*n
module gea(num, radii)
{
polygon([for (i=[0:num-1], a=i*360/num, r=radii[i%len(radii)]) [ r*cos(a), r*sin(a) ]]);
}
module gear()
{
linear_extrude(height = 8, center=true)
gea(n*4, [R-t,R+t,R+t,R-t], center=true);
}
cylinder(r=10, h=90, center=true);
gear(R=25, t=1.7, n=25);
I'm not quite sure that I understand your need, but would it work to
just rotate the model so that its nominal Y axis is along the Z axis in
the OpenSCAD viewer?
You could then easily view it from a point perpendicular to that axis,
and rotate it around that axis.
I just mean
rotate([90,0,0]) mymodel();
Here's a fancy implementation using the customizer to control whether to
be in this "view mode"...
viewMode = false;
module maybeRotate() {
if (viewMode) rotate([90,0,0]) children();
else children();
}
module mymodel() {
cube([1,10,1], center=true);
}
maybeRotate() mymodel();
It might also be helpful to use Shift+LeftDrag to move the Z axis into
some other position, and then use ordinary LeftDrag to rotate around it.
I kind of thought there was a way to rotate around Y or Z, but right now
I'm not finding it.
Jordan Brown wrote:
I'm not quite sure that I understand your need
Sorry, I missed out half the story: I also want the xyz symbol that appears bottom left of the viewport when the axes are displayed, and which tells you which axis is which, to be the right way round, i.e. z and x horizontal and y vertical. If we are talking about an IC engine, the crankshaft should be on the z-axis and the cylinder on the y-axis. (The cylinders of a “boxer” would be on the x-axis.)
Then, as already mentioned, i want to be able to rotate the model about the y-axis instead of the z-axis, using the cursor. At hte moment, it is not possible to rotate the model in a meaningful way using the cursor, it just goes head over heels. That can only be done with $vpr. The mouse can only be moved in 2 dimensions and unfortunately it controls the wrong pair of dimensions for a machine.
Is that better?
Here's a fancy implementation using the customizer to control whether to
be in this "view mode"...
viewMode = false;
module maybeRotate() {
if (viewMode) rotate([90,0,0]) children();
else children();
}
module mymodel() {
cube([1,10,1], center=true);
}
maybeRotate() mymodel();
Doesn’t seem to work with me/nothing happens when i change the values in “rotate”.
It might also be helpful to use Shift+LeftDrag to move the Z axis into
some other position, and then use ordinary LeftDrag to rotate around it.
Eureca! Shift and mouse left button does the trick, but it needs both hands. I’m a bit lazy. Can OpenSCAD be set up to do it single-handed just with the mouse?
On 8/18/2023 10:38 PM, mikeonenine@web.de wrote:
Is that better?
Yes, though I don't know an easy way to do exactly what you say, making
it easy to hold the Y axis in one place and spin around it.
Here's a fancy implementation using the customizer to control
whether to
be in this "view mode"...
|viewMode = false; module maybeRotate() { if (viewMode)
rotate([90,0,0]) children(); else children(); } module mymodel() {
cube([1,10,1], center=true); } maybeRotate() mymodel(); |
Doesn’t seem to work with me/nothing happens when i change the values
in “rotate”.
This isn't an answer to your problem, since you want the XYZ indicator
to be "correct". However, just so it isn't left out there as a
confusing contribution...
The intent is that this is an easy way to flip the model onto a
different axis for viewing. Use Window/Customizer to display the
customizer. If this tidbit (except for "mymodel", which should be
replaced by your model) at the top of the file, the customizer should
offer you a "viewMode" checkbox. Checking the checkbox should flip the
model so that its original Y axis is along the Z axis.
It might also be helpful to use Shift+LeftDrag to move the Z axis
into
some other position, and then use ordinary LeftDrag to rotate
around it.
Eureca! Shift and mouse left button does the trick,
I'm glad it works for you. That mode makes my head hurt; I haven't been
able to internalize what it really means and so I end up randomly
spinning the model until it somehow ends up where I want it.
but it needs both hands. I’m a bit lazy. Can OpenSCAD be set up to do
it single-handed just with the mouse?
I don't believe so. Using a joystick or a SpaceMouse or other auxiliary
input device i believe you can do custom rotates and translates using
Edit/Preferences/Axes, but the same customization is not available for
the mouse or keyboard. (Though I do wonder whether the mouse operation
could be made to fit into that infrastructure and enable mouse
customization. Maybe a future project.)
Jordan Brown wrote:
It might also be helpful to use Shift+LeftDrag to move the Z axis
into
some other position, and then use ordinary LeftDrag to rotate
around it.
Eureca! Shift and mouse left button does the trick,
I'm glad it works for you. That mode makes my head hurt; I haven't been
able to internalize what it really means and so I end up randomly
spinning the model until it somehow ends up where I want it.
I should add that the y-axis needs to be vertical to start with. Clicking on the second from left cube-with-a-spike icon at the bottom of the GUI does that, if the y-axis has not already been set vertical with $vpr. With a finger on the shift key, the y-axis stays put while the model is turned to show a particular feature more clearly or to find the optimum orientation for a copy of the viewport or an animation. Unfortunately the caps lock key doesn’t have the same effect, so you have to keep a finger on shift, which I find a bit awkward, but miles better than incremental adjustments of $vpr.