If you want to do a set of sun and planet gears, you might want a carrier for the planets. This code gives polygons with convex or concave sides as well as some wierd stuff, if you like that sort of thing.
$fn=100;
n=4; // number of sides
module squircle()
{
polygon([
for(i = [0:2:360])
[R*r*sin(i)+r*cos((n-1)*i), R*r*cos(i)+r*sin((n-1)*i)],
]);
}
module carr()
offset(-6)
offset(6)
difference()
{
union()
{
rotate([0, 0, 22.5])
offset(-6)
difference()
{
squircle(R=6.1, r=11.2);
squircle(R=14.3, r=2.5);
}
for (i=[0:90:270])
rotate([0, 0, i])
translate([60, 0])
circle(d+5);
}
for (i=[0:90:270])
rotate([0, 0, i])
translate([60, 0])
circle(d);
}
module carrier()
rotate([0,0,90-$t*360])
translate([0,e,0])
rotate([0,0,-90+$t*360])
{
difference()
{
linear_extrude(10, center=true, convexity=3)
carr(d=9);
translate([0, 0, 3.1])
linear_extrude(4, center=true)
offset(2)
offset(-5)
carr(d=11);
translate([0, 0, -3.1])
linear_extrude(4, center=true)
offset(2)
offset(-5)
carr(d=11);
}}
rotate([0,0,$t*90])
carrier();
Have fun adjusting the parameters!
But I’m not quite sure if it is possible to animate sun and planet gears. Has anyone done it?
Nice model.
Huh. I didn't know that formal parameter specifications were optional.
module x() { echo(a); }
x(a=5);
works, to my surprise.
But still you might want to add the formal parameters (R, r for
squircle() and d for carr()). to avoid the warning messages.
You have an undefined variable "e" used in the translate in carrier().
Jordan Brown wrote:
Nice model.
Huh. I didn't know that formal parameter specifications were optional.
But still you might want to add the formal parameters (R, r for
squircle() and d for carr()). to avoid the warning messages.
Ah, so that’s what they are for. I never bothered with them in the past, as they didn’t seem to do anything, and ignored the error messages - if the code works, that’s good enough for me. But now I know where all the error messages come from!
You have an undefined variable "e" used in the translate in carrier().
Oh yes, thank you. That must have crept in from another project. In fact all 3 of those animation lines are superfluous. The animaton comes at the end, but should probably read rotate([0,0,$t*360/n]) for this particular application.
Insert rotate([0,0,75/n -14-n]) in the squircle module and the carrier always comes out with one corner at the top, whatever the number of sides - well, more or less. I derived that from a plot of rotation against number of sides, not by calculation from first principles.
BTW I like center=true. It’s very handy e.g. for cutouts: once you have worked out the correct depth on one side, the other side is the same but with the opposite sign (see code above). Should be possible to select it as the default value.
Many people run with "stop on first warning" which means if your program
produces any yellow warning messages, it won't work. I recommend not
distributing models that produce warnings. Also, without those formal
parameter specifications, another user can't tell how to use your code.
Has anybody animated sun and planet gears? Of course.
https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad#functionmodule-spur_gear
See the spur gear module, section 8 above. Be warned that the gears code
is under development right now. It was found to be producing invalid
gears, and the fixes may not yet be entirely complete.
On Wed, Aug 2, 2023 at 1:36 AM mikeonenine@web.de wrote:
Jordan Brown wrote:
Nice model.
Huh. I didn't know that formal parameter specifications were optional.
But still you might want to add the formal parameters (R, r for squircle()
and d for carr()). to avoid the warning messages.
Ah, so that’s what they are for. I never bothered with them in the past,
as they didn’t seem to do anything, and ignored the error messages - if the
code works, that’s good enough for me. But now I know where all the error
messages come from!
You have an undefined variable "e" used in the translate in carrier().
Oh yes, thank you. That must have crept in from another project. In fact
all 3 of those animation lines are superfluous. The animaton comes at the
end, but should probably read rotate([0,0,$t*360/n]) for this particular
application.
Insert rotate([0,0,75/n -14-n]) in the squircle module and the carrier
always comes out with one corner at the top, whatever the number of sides -
well, more or less. I derived that from a plot of rotation against number
of sides, not by calculation from first principles.
BTW I like center=true. It’s very handy e.g. for cutouts: once you have
worked out the correct depth on one side, the other side is the same but
with the opposite sign (see code above). Should be possible to select it as
the default value.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 8/2/23 01:37, mikeonenine@web.de wrote:
Jordan Brown wrote:
Nice model.
Huh. I didn't know that formal parameter specifications were optional.
But still you might want to add the formal parameters (R, r for
squircle() and d for carr()). to avoid the warning messages.
Ah, so that’s what they are for. I never bothered with them in the past,
as they didn’t seem to do anything, and ignored the error messages - if
the code works, that’s good enough for me. But now I know where all the
error messages come from!
You have an undefined variable "e" used in the translate in carrier().
Oh yes, thank you. That must have crept in from another project. In fact
all 3 of those animation lines are superfluous. The animaton comes at
the end, but should probably read rotate([0,0,$t*360/n]) for this
particular application.
Insert rotate([0,0,75/n -14-n]) in the squircle module and the carrier
always comes out with one corner at the top, whatever the number of
sides - well, more or less. I derived that from a plot of rotation
against number of sides, not by calculation from first principles.
BTW I like center=true. It’s very handy e.g. for cutouts: once you have
worked out the correct depth on one side, the other side is the same but
with the opposite sign (see code above). Should be possible to select it
as the default value.
+50 Since I discovered that a year+ back up the log, I have not written
a line of 3d code w/o it. center=true s/b the default. Unforch, it
would break at least half the code ever written. I'd settle for once at
the top of the file so its global in scope. Or does that work now? No.
"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 8/2/23 06:36, Adrian Mariano wrote:
Many people run with "stop on first warning" which means if your program
produces any yellow warning messages, it won't work. I recommend not
distributing models that produce warnings. Also, without those formal
parameter specifications, another user can't tell how to use your code.
Has anybody animated sun and planet gears? Of course.
https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad#functionmodule-spur_gear https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad#functionmodule-spur_gear
very very impressive Adrian. Thank you. But, I don't see any examples of
a buttress thread.
So I've hand edited a 6 point polygon, following 1 of the 4 variatons of
buttress threading. then 3d'd it, then used that as the tooth form
wrapped around a cylinder as the mandrel in a 2 start form making it
.45mm bigger to compensate for printer nozzle size as it then
difference()ed half its overall diameter with a cube to make the half
nuts. Render time is not speedy but still many times faster than the
printer, or my rebuilt 6040 mill carving the screw from a 22" long hard
maple 2x2. With a 1/16" round nosed SC tool, and no tool changer to do
the roughing cuts, its about 2 days a screw. And about 2 weeks per
screw to print the rest of it so its a ready to install on your
workbench product. So printer speed is the major time waster. I'm
currently mid project of making a B axis for a bigger mill to do the
roughing/rounding of that stick, which should put me up to three sticks
a day.
Could this 6 point 2d polygon be used by your library as a tooth form?
See the spur gear module, section 8 above. Be warned that the gears
code is under development right now. It was found to be producing
invalid gears, and the fixes may not yet be entirely complete.
On Wed, Aug 2, 2023 at 1:36 AM <mikeonenine@web.de
mailto:mikeonenine@web.de> wrote:
Jordan Brown wrote:
Nice model.
Huh. I didn't know that formal parameter specifications were
optional.
But still you might want to add the formal parameters (R, r for
squircle() and d for carr()). to avoid the warning messages.
Ah, so that’s what they are for. I never bothered with them in the
past, as they didn’t seem to do anything, and ignored the error
messages - if the code works, that’s good enough for me. But now I
know where all the error messages come from!
You have an undefined variable "e" used in the translate in
carrier().
Oh yes, thank you. That must have crept in from another project. In
fact all 3 of those animation lines are superfluous. The animaton
comes at the end, but should probably read rotate([0,0,$t*360/n])
for this particular application.
Insert rotate([0,0,75/n -14-n]) in the squircle module and the
carrier always comes out with one corner at the top, whatever the
number of sides - well, more or less. I derived that from a plot of
rotation against number of sides, not by calculation from first
principles.
BTW I like center=true. It’s very handy e.g. for cutouts: once you
have worked out the correct depth on one side, the other side is the
same but with the opposite sign (see code above). Should be possible
to select it as the default value.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
<mailto:discuss-leave@lists.openscad.org>
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
"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 8/1/2023 10:36 PM, mikeonenine@web.de wrote:
Huh. I didn't know that formal parameter specifications were
optional.
But still you might want to add the formal parameters (R, r for
squircle() and d for carr()). to avoid the warning messages.
Ah, so that’s what they are for. I never bothered with them in the
past, as they didn’t seem to do anything, and ignored the error
messages - if the code works, that’s good enough for me. But now I
know where all the error messages come from!
In addition to the documentation aspect that Adrian mentions, declaring
the formal parameters, and warning when you supply an argument that
isn't declared, catches typos.
module foo(center) {
... do something with center ...
}
foo(centre=true);
Without the formal parameter and the associated warning, the error would
be silently ignored.
Also... ignoring warnings makes it much harder to notice the warnings
that you actually care about.
Yes, there's a good argument that center should be the default. There's
also good arguments against it. For better or worse, it can't be
changed now. (You could maybe imagine a $center that would supply the
default for subsequent calls, but you would then be unable to use any
existing library.)
However, it's easy enough to work around:
module ccube(size, center=true) {
cube(size=size, center=center);
}
I personally use a "justified cube" function jcube() that accepts a vec3
of justification values, justifying independently in each of the three
axes. -1 puts the cube on the negative side of the origin, 0 centers,
and +1 puts it on the positive side.
(I started to build a full set of justified functions, but it's
surprisingly unobvious how justified circles should work.)
Gene, not sure what's wrong with these buttress thread examples:
https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-buttress_threaded_rod
If you want arbitrary threads you can build your own thread profile as a
point list and pass it to the generic threading code:
https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-generic_threaded_rod
On Wed, Aug 2, 2023 at 1:07 PM gene heskett gheskett@shentel.net wrote:
On 8/2/23 06:36, Adrian Mariano wrote:
Many people run with "stop on first warning" which means if your program
produces any yellow warning messages, it won't work. I recommend not
distributing models that produce warnings. Also, without those formal
parameter specifications, another user can't tell how to use your code.
Has anybody animated sun and planet gears? Of course.
https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad#functionmodule-spur_gear
<
https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad#functionmodule-spur_gear
very very impressive Adrian. Thank you. But, I don't see any examples of
a buttress thread.
So I've hand edited a 6 point polygon, following 1 of the 4 variatons of
buttress threading. then 3d'd it, then used that as the tooth form
wrapped around a cylinder as the mandrel in a 2 start form making it
.45mm bigger to compensate for printer nozzle size as it then
difference()ed half its overall diameter with a cube to make the half
nuts. Render time is not speedy but still many times faster than the
printer, or my rebuilt 6040 mill carving the screw from a 22" long hard
maple 2x2. With a 1/16" round nosed SC tool, and no tool changer to do
the roughing cuts, its about 2 days a screw. And about 2 weeks per
screw to print the rest of it so its a ready to install on your
workbench product. So printer speed is the major time waster. I'm
currently mid project of making a B axis for a bigger mill to do the
roughing/rounding of that stick, which should put me up to three sticks
a day.
Could this 6 point 2d polygon be used by your library as a tooth form?
See the spur gear module, section 8 above. Be warned that the gears
code is under development right now. It was found to be producing
invalid gears, and the fixes may not yet be entirely complete.
On Wed, Aug 2, 2023 at 1:36 AM <mikeonenine@web.de
mailto:mikeonenine@web.de> wrote:
Jordan Brown wrote:
Nice model.
Huh. I didn't know that formal parameter specifications were
optional.
But still you might want to add the formal parameters (R, r for
squircle() and d for carr()). to avoid the warning messages.
Ah, so that’s what they are for. I never bothered with them in the
past, as they didn’t seem to do anything, and ignored the error
messages - if the code works, that’s good enough for me. But now I
know where all the error messages come from!
You have an undefined variable "e" used in the translate in
carrier().
Oh yes, thank you. That must have crept in from another project. In
fact all 3 of those animation lines are superfluous. The animaton
comes at the end, but should probably read rotate([0,0,$t*360/n])
for this particular application.
Insert rotate([0,0,75/n -14-n]) in the squircle module and the
carrier always comes out with one corner at the top, whatever the
number of sides - well, more or less. I derived that from a plot of
rotation against number of sides, not by calculation from first
principles.
BTW I like center=true. It’s very handy e.g. for cutouts: once you
have worked out the correct depth on one side, the other side is the
same but with the opposite sign (see code above). Should be possible
to select it as the default value.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
<mailto:discuss-leave@lists.openscad.org>
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
"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.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 8/2/23 15:59, Adrian Mariano wrote:
Gene, not sure what's wrong with these buttress thread examples:
https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-buttress_threaded_rod https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-buttress_threaded_rod
TBT, nothing once I'd read the docs. And I had no idea BOSL2 could do that.
Obviously I'd have to learn how to use it but all the vars are there. My
version uses the 7 degree face on the load face and cheats a wee bit on
the rest because of the available tool shape. The 7 degree load face
encourages the self centering aspect, evening the load per sq on the
thread, and tool shape is 1/16" rn tool with .25" LOC. I get the 7
degrees from a tapered pad under the spindle motor, so my polygon is
indeed flat faced.
Bookmarked FFR, I'll have to check it out, thank you very much Adrian.
What I have now is so close I'm using the shrinkage factor in Cura to
fine tune the plastic so all 14 engaged teeth carry the load. Equ to
speccing the pitch to about 5 or 6 places right of the decimal point.
If you want arbitrary threads you can build your own thread profile as a
point list and pass it to the generic threading code:
https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-generic_threaded_rod https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-generic_threaded_rod
"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.
Jordan Brown wrote:
However, it's easy enough to work around:
module ccube(size, center=true) {
cube(size=size, center=center);
}
Yes, that will be useful. It works for cubes with different side lengths in square brackets too:
module ccube(size, center=true)
{
cube(size=size, center=center);
}
ccube([20, 30, 40]);
What is a vec3 of justification values? A "translate([x,y,z])" in the module, where x, y and z are 0 or the negative side length?
Adrian Mariano wrote:
Has anybody animated sun and planet gears? Of course.
https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad#functionmodule-spur_gear
See the spur gear module, section 8 above. Be warned that the gears code
is under development right now. It was found to be producing invalid
gears, and the fixes may not yet be entirely complete.
On Wed, Aug 2, 2023 at 1:36 AM mikeonenine@web.de wrote:
Jordan Brown wrote:
Nice model.
Huh. I didn't know that formal parameter specifications were optional.
But still you might want to add the formal parameters (R, r for squircle()
and d for carr()). to avoid the warning messages.
Ah, so that’s what they are for. I never bothered with them in the past,
as they didn’t seem to do anything, and ignored the error messages - if the
code works, that’s good enough for me. But now I know where all the error
messages come from!
You have an undefined variable "e" used in the translate in carrier().
Oh yes, thank you. That must have crept in from another project. In fact
all 3 of those animation lines are superfluous. The animaton comes at the
end, but should probably read rotate([0,0,$t*360/n]) for this particular
application.
Insert rotate([0,0,75/n -14-n]) in the squircle module and the carrier
always comes out with one corner at the top, whatever the number of sides -
well, more or less. I derived that from a plot of rotation against number
of sides, not by calculation from first principles.
BTW I like center=true. It’s very handy e.g. for cutouts: once you have
worked out the correct depth on one side, the other side is the same but
with the opposite sign (see code above). Should be possible to select it as
the default value.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I wondered, because I had found a while back that toothed belts can only be used in a very limited way in conjunction with cogwheels. The wheels have to have 20 teeth and the belt 47 (forty-seven) or a multiple thereof, among other things. Why 47?
On 8/3/2023 7:47 PM, mikeonenine@web.de wrote:
||
|What is a vec3 of justification values? A "translate([x,y,z])" in the
module, where x, y and z are 0 or the negative side length?|
First, by a vec3 I mean a vector/list/array of three numbers.
My jcube module takes two arguments: a value or vec3 for the size, and
a justification vec3.
The justification vec3 controls alignment in each of the three axes.
For each axis, -1 puts the cube to the negative side of the origin, 0
centers it on the origin, and +1 puts it on the positive side of the origin.
Thus, e.g.:
jcube(10, j=[1,1,1]);
yields a standard cube in +XYZ.
jcube(10, j=[0,0,0]);
yields a cube that is centered on the origin.
jcube(10, j=[-1,1,0]);
yields a cube that is left of the origin (in -X), in +Y, and centered in Z:
Here's a simplified version of my module. (The real one is part of a
larger justify-anything library that isn't ready for prime time.)
// A justified cube
// dims Dimensions of the cube
// j [jx,jy,jz]:
// +1 toward-positive
// 0 center
// -1 toward-negative
module jcube(dims, j=[1,1,1]) {
dims = is_list(dims) ? dims : [dims, dims, dims];
function o(flag, dim) =
flag > 0 ? 0
: flag < 0 ? -dim
: -dim/2;
translate([o(j[0], dims[0]),
o(j[1], dims[1]),
o(j[2], dims[2])])
cube(dims);
}
One small piece of trickery: we say that you can't change the values of
variables, and this seems to violate that rule. It really doesn't,
because you're allowed to create new variables in inner scopes, and
the definition of those new variables can use the variables from the
outer scope. The argument "dims" is in one scope, and in an inner scope
the assignment creates a new variable "dims". I could have used a
different name, but this style seems less cluttered.
You might also consider a library like BOSL2
https://github.com/BelfrySCAD/BOSL2/wiki. BOSL2's cube()
https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-cube
provides an equivalent in its "anchor" feature, and much much more.
Consider mine to be more of a first-principles demonstration.
Jordan Brown wrote:
On 8/3/2023 7:47 PM, mikeonenine@web.de wrote:
||
|What is a vec3 of justification values? A "translate([x,y,z])" in the
module, where x, y and z are 0 or the negative side length?|
First, by a vec3 I mean a vector/list/array of three numbers.
My jcube module takes two arguments: a value or vec3 for the size, and
a justification vec3.
The justification vec3 controls alignment in each of the three axes.
For each axis, -1 puts the cube to the negative side of the origin, 0
centers it on the origin, and +1 puts it on the positive side of the origin.
Thus, e.g.:
jcube(10, j=[1,1,1]);
yields a standard cube in +XYZ.
jcube(10, j=[0,0,0]);
yields a cube that is centered on the origin.
jcube(10, j=[-1,1,0]);
yields a cube that is left of the origin (in -X), in +Y, and centered in Z:
Here's a simplified version of my module. (The real one is part of a
larger justify-anything library that isn't ready for prime time.)
// A justified cube
// dims Dimensions of the cube
// j [jx,jy,jz]:
// +1 toward-positive
// 0 center
// -1 toward-negative
module jcube(dims, j=[1,1,1]) {
dims = is_list(dims) ? dims : [dims, dims, dims];
function o(flag, dim) =
flag > 0 ? 0
: flag < 0 ? -dim
: -dim/2;
translate([o(j[0], dims[0]),
o(j[1], dims[1]),
o(j[2], dims[2])])
cube(dims);
}
One small piece of trickery: we say that you can't change the values of
variables, and this seems to violate that rule. It really doesn't,
because you're allowed to create new variables in inner scopes, and
the definition of those new variables can use the variables from the
outer scope. The argument "dims" is in one scope, and in an inner scope
the assignment creates a new variable "dims". I could have used a
different name, but this style seems less cluttered.
You might also consider a library like BOSL2
https://github.com/BelfrySCAD/BOSL2/wiki. BOSL2's cube()
https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-cube
provides an equivalent in its "anchor" feature, and much much more.
Consider mine to be more of a first-principles demonstration.
Oh dear, I wish I hadn't asked! It's neat, it works nicely, but it contains an exponential increase of stuff that I don't understand. I think I'll stick with your previous module. Then there is the question of more complex one-off shapes like the side cutouts in the planet gear carrier (above).
Center=false is of course needed for rotate_extrude and I recently did a T-piece with the crossbar center=true and the leg center=false so that it starts in the middle of the crossbar and can be lengthened in one direction only instead of going both ways.
What do you call a squircle with any number of sides? A polycle? a circlegon? My module (above) contains an error, which is why it is so difficult to get the orientation right. The corrected module is:
module polycle(n, R, r)
{
rotate([0,0,90/n])
polygon([
for(i = [0:5:355])
[R*sin(i)+r*cos((n-1)*i), R*cos(i)+r*sin((n-1)*i)],
]);
}
Where:
n = number of sides
R = pitch circle radius
r = half-height of lobes
(Of course, it won’t work in the carrier script now as it stands.)
On 8/4/2023 8:17 PM, mikeonenine@web.de wrote:
Oh dear, I wish I hadn't asked! It's neat, it works nicely, but it
contains an exponential increase of stuff that I don't understand.
I will be happy to explain anything you're having trouble with. Here's
a quick start...
|// A justified cube // dims Dimensions of the cube // j [jx,jy,jz]:
// +1 toward-positive // 0 center // -1 toward-negative // //
Default justification is [1,1,1], a normal +XYZ cube module
jcube(dims, j=[1,1,1]) { // If dims is a [x,y,z] list, use it, else
(if it's a plain // number) duplicate it three times to form a
[x,y,z]. dims = is_list(dims) ? dims : [dims, dims, dims]; // Given
a justification value and a dimension, this function // calculates
the offset required in that dimension. function o(flag, dim) = flag
0 ? 0 : flag < 0 ? -dim : -dim/2; // Create a cube, and translate
it appropriately in each of the three // dimensions. translate([
o(j[0], dims[0]), o(j[1], dims[1]), o(j[2], dims[2]) ]) cube(dims); }|
I think I'll stick with your previous module. Then there is the
question of more complex one-off shapes like the side cutouts in the
planet gear carrier (above).
I'm afraid I didn't look at your model in that much detail.
The same basic justification principle can be applied to other shapes -
and I have applied it to a few, like polygons, in some of my projects.
It's hard to apply in general, because you have to know the bounding box
of the object and current OpenSCAD doesn't have a way to find that for a
general object.
Center=false is of course needed for rotate_extrude
It's a little hard to see what center=false would mean for rotate_extrude.
Jordan Brown wrote:
I will be happy to explain anything you're having trouble with. Here's
a quick start...
|// A justified cube // dims Dimensions of the cube // j [jx,jy,jz]:
// +1 toward-positive // 0 center // -1 toward-negative // //
Default justification is [1,1,1], a normal +XYZ cube module
jcube(dims, j=[1,1,1]) { // If dims is a [x,y,z] list, use it, else
(if it's a plain // number) duplicate it three times to form a
[x,y,z]. dims = is_list(dims) ? dims : [dims, dims, dims]; // Given
a justification value and a dimension, this function // calculates
the offset required in that dimension. function o(flag, dim) = flag
0 ? 0 : flag < 0 ? -dim : -dim/2; // Create a cube, and translate
it appropriately in each of the three // dimensions. translate([
o(j[0], dims[0]), o(j[1], dims[1]), o(j[2], dims[2]) ]) cube(dims); }|
That looks interesting. I have started a “dictionary” and put it in there. I must try it out. But as you said, it's hard to apply in general, which I imagine would apply to the cutouts in my squircle carrier design, as they are not standard shapes … unless the principle can be applied to linear_extrude … hmmm.
I'm afraid I didn't look at your model in that much detail.
The cutouts are the green bits if you use the default colour scheme. If everything is center=true, it is easier to get them the same depth both back and front.
It's a little hard to see what center=false would mean for rotate_extrude.
Rotate_extrude doesn’t work if the square or whatever straddles the y-axis, which is the case if centre=true. The whole square has to be one side or the other, which is the case if centre=false. So in this case, the default value is useful. But on balance, I seem to use “true” more often than “false” and so would like to be able to select the default value for each project.
These don’t work, because the squares overlap the y-axis:
rotate_extrude()
square(10, center=true);
rotate_extrude()
offset(2)
square(10);