solidboredom / constructive

Extends OpenScad Language for complex and complementary mechanical parts with less mathematical code. Offers a "Stamping" approach to quickly create mechanical parts fitting and complementing one another. This is used as a replacement for Constraints known form other CAD systems
Other
57 stars 8 forks source link

`chamfer()` changes box dimensions? #3

Open rjp opened 1 year ago

rjp commented 1 year ago

box(2) gives a 2x2x2 box as expected (https://rjp.is/stls/nochambox2.stl)

chamfer(0,0,0) box(2) gives a 2x2x2.06 box (https://rjp.is/stls/cham0box2.stl)

chamfer(0, -0.1, -0.1) box(2) gives a 2x2x2.03 box (https://rjp.is/stls/cham0101box2.stl).

Seems to stabilise at 2.03 as you increase those two values.

Oddly chamfer(-0.1, -0.3, -0.3) box(2) gives an exact 2x2x2 box (https://rjp.is/stls/cham010303.stl) - it seems that if the first value is not 0, you'll get the height you requested (even with a skirt chamfer.)

I can work around this by making my chamfered boxes a little taller than required and clipping them down but is there a way to get a chamfered top-and-sides box with an exact height?

(All measurements via stl_bbox from https://github.com/AllwineDesigns/stl_cmd.git )

solidboredom commented 1 year ago

Hello Rjp, thanks for Opening an Issue. Yes, this it is known, it just was not an Issue so far, in many many years of my use of Constructive.,. the Change is very slight, i have never even noticed it myself constructing few centimetres sized FFD printable objects with a Consumer-Grade Printer, but if you are creating small objects of few millimetres across like yours,it can be very noticeable. The Reason for dimensional change is to make Openscad render the objects properly in the preview. You probably have seen yourself, that Openscad produces visual artifacts, or can even fail rendering with F6 if you have two objects share exatly the same edge on object added and the other one subtracted with an adjacent edge. Espeacially when using extrusions(which are user for box and tube) so this margin is a toll to pay,right now. Actually one could be more clever inside the box() and tube() modules to avoid dimension change, or perhaps just add an Adjustable global variable like the one returned by the margin() function (which one could use to compensates for 3D-printing imprecisions, when printing fitting Parts). Then inside the box() and tube() it could be used with something called like visaulCorrectionMargin() instead of using a fixed Value,like now. I think the last would be easiest to do. Just not sure when i will have time for it. Would you like to help there? Peter