Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New generator: FlexBook #643

Merged
merged 3 commits into from
Mar 12, 2024
Merged

Conversation

ojensen5115
Copy link
Contributor

@ojensen5115 ojensen5115 commented Mar 4, 2024

A box with flex that is styled after a hardcover book. Photos included.

image

@ojensen5115
Copy link
Contributor Author

Fixed copyright notice on the generator, since it seems from other generators that generator authors are intended to put their own details there.

@ojensen5115 ojensen5115 changed the title New generator: flexbook New generator: FlexBook Mar 11, 2024
@florianfesti florianfesti merged commit cf56881 into florianfesti:master Mar 12, 2024
7 checks passed
@florianfesti
Copy link
Owner

Very nice work! Thanks for the generator!

@ojensen5115
Copy link
Contributor Author

@florianfesti When I construct a piece from edges and corners and put it next to a rectangularWall, it ends up slightly lower and to the right -- it's like there's some kind of special margin built in to the pieces that doesn't get applied when constructing pieces out of edges. Moreover, I've found that even inside the piece, things can be off by the width of the burn correction.

Here is a minimal example:

def pinHoles(self, width, height):
    t = self.thickness
    self.rectangularHole(width/2, 1.5*t, t, t),
    self.rectangularHole(width/2, height-1.5*t, t, t)

x = 30
y = 20

self.rectangularWall(x, y, move="right", callback=[lambda: self.pinHoles(x, y)],)

self.pinHoles(x, y)
self.edges["e"](x)
self.corner(90)
self.edges["e"](y)
self.corner(90)
self.edges["e"](x)
self.corner(90)
self.edges["e"](y)
self.corner(90)

In the output, the two pieces have a small vertical offset:

image

After aligning the pieces to overlap perfectly, the pin holes are vertically off by the burn correction (in my case 0.12 mm):

image

Since I don't understand what's happening here, I've generally avoided mixing the two styles of constructing pieces.

@florianfesti
Copy link
Owner

florianfesti commented Mar 16, 2024

There are two different things at play:

Boxes.move - which is used by all parts (see https://florianfesti.github.io/boxes/html/api_parts.html) - adds a bit of space round the pieces to they do not touch each other. The value used is Boxes.spacing. This is the reason why the rectangles are not aligned the same way. Using Boxes.move would fix that.

The second thing is the burn correction. See https://florianfesti.github.io/boxes/html/api_burn.html

Basically the bottom line is one Boxes.burn below the nominal area of the piece. As such the holes in the middle need to be one .burn higher. .cc() that handles callbacks does that semi automatically by having the default offset for y as None which is translated to Boxes.burn

Because of these issues it is better to use callbacks as this separates the caring for those offsets from the stuff being drawn onto the piece.

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