Skip to content

Add orient parameter to slot() shape#89

Open
kesor wants to merge 1 commit intorevarbat:masterfrom
kesor:master
Open

Add orient parameter to slot() shape#89
kesor wants to merge 1 commit intorevarbat:masterfrom
kesor:master

Conversation

@kesor
Copy link

@kesor kesor commented Jan 2, 2022

The slot() documentation said there should be orient in there, but it was missing.

Copy link
Contributor

@fe60 fe60 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the orientation of the cylinders only won't work.
Simple example:
slot(r=5, h=3, l=20, orient=ORIENT_X);
Resulting solid:
BOSL_PR89_example

I think you will have to arrange the whole object using orient_and_align() as soon as
orient != undef or align != undef

r=undef, r1=undef, r2=undef,
d=undef, d1=undef, d2=undef
d=undef, d1=undef, d2=undef,
orient=undef
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
orient=undef
align=V_CENTER, orient=ORIENT_Z

r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=5);
sides = quantup(segs(max(r1, r2)), 4);
hull() spread(p1=p1, p2=p2, l=l, n=2) cyl(l=h, r1=r1, r2=r2, center=true, $fn=sides);
hull() spread(p1=p1, p2=p2, l=l, n=2) cyl(l=h, r1=r1, r2=r2, center=true, $fn=sides, orient=orient);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hull() spread(p1=p1, p2=p2, l=l, n=2) cyl(l=h, r1=r1, r2=r2, center=true, $fn=sides, orient=orient);
if (align!=V_CENTER || orient!=ORIENT_Z) {
orient_and_align(size=[l+2*r1, 2*r1, h], orient=orient, align=align, orig_orient=ORIENT_Z, orig_align=V_CENTER)
solid();
} else {
solid();
}
module solid()
{
hull() spread(p1=p1, p2=p2, l=l, n=2) cyl(l=h, r1=r1, r2=r2, align=V_CENTER, orient=ORIENT_Z, $fn=sides);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants