Dogbone fillet and other drawing improvements
I'm looking for a way to create dogbone fillets for cnc machine. I know it can be done with some math and arcs but wonder if it can be done better. the .customCorner(fillet) is a charm - and I was expecting it will work exactly as dogbone with negative values - but it seems like behaviour is determined by abs value so -4 and 4 give identical results.
Also, it'd be nice to collect the current points as we draw (although I'm not sure this is possible):
const points = [];
s
.vLineTo(10)
.savePosition((p) => points.push[p])
.hLineTo(10)
.savePosition((p) => points.push[p])
Then we just iterate points and cut holes as we need.
to go further, tags would also be nice to have:
s
.vLineTo(10, {tag: 'dogbone1'})
.done()
s.select(v => v.tag.includes('dogbone')).map(v => v.[start|end|params|length|etc])
s.select(v => someTag) // we don't even need to draw in some cases - just extract some points (which otherwise hard to calculate) to create 3d wires.
This alone will cover lots of use-cases.
To summarise:
- Can .customCorner be changed to work with negative values? (I understand that's a braking change)
- Why there is no customCorner for Sketcher?
- In general, I see a use-case for draw() to be some calculation helper as well as drawer - is something mentioned above possible?
Can .customCorner be changed to work with negative values? (I understand that's a braking change)
I have started working on a customCorner(2, "dogbone") type of corner. But I am not sure what the definition of a dogbone corner is (and how it relates to its radius). Do you have a definition for this?
I am also thinking of exposing more of the custom corner machinery, to allow the customCorner to take a function with two curves are parameters that returns an array of curves (and let you create your own specialized function).
Why there is no customCorner for Sketcher?
The sketcher is a bit weird. It works with 3D curves. They are all in the same plane, so in theory we could do some customCorners, but it is more complicated (i.e. we need to go back in 2D to then go back in 3D). Generally I prefer that people use the drawing tool instead of sketching (as everything there is in 2D).
In general, I see a use-case for draw() to be some calculation helper as well as drawer - is something mentioned above possible?
You can even get some of this information directly.
const points = [];
s = s.vLineTo(10)
points.push(s.pointer)
s = s.hLineTo(10)
points.push(s.pointer)
I am not 100% keen on tagging / saving the position, as the custom corners can change the geometry (and then we get into interpreting what the tag references to).
There is a CornerFinder in the spirit of the FaceFinder used in 3D filletting that is exposed in the 2D filletting operations, a CurveFinder could also be implemented to query the object. Would that help you? Could you use the corner finder as it is now as well?
I have cut on CNC only once using makerJS, so I can only relate to it's implementation and general sense. The dogbone at corner is a minimal cutout (of round tool) so the corner would fit a square. https://maker.js.org/playground/?script=Dogbone
There is also T-bone and run-past for the sake of completeness. https://fabacademy.org/2021/labs/zoi/week7_ccm.html#:~:text=adapt%20your%20design.-,Dog%20bones%20/%20T%20bones,-To%20understand%20why
I remember the impression that the maker api was dead simple - it was both frustrating (I had to make my own draw class) and appealing (the drawing is just a json - I can hack whatever I want) Although with regards to custom corners the have interesting chain api: https://maker.js.org/docs/working-with-chains/#Chain%20fillet https://maker.js.org/docs/working-with-chains/#Chain%20dogbone (note left/right params)
With replicad's draw I've got quite opposite impression - the api is a joy most of the time but sometimes I miss the hacks were available to me at makerjs - the drawing is just a combination of lines and arcs.
I'm aware of #144 but let me leave these thoughts here for the sake of future discussion
There is a
CornerFinder
Could we somehow find all "left" or "right" corners? That'd be helpful for dogbone fillets.
The other issue I have encountered:
You can only move the pointer if there is no curve defined
Is there a technical reason behind? We could (I think) otherwise draw some interesting shapes:
d
.polarLine(r, 0)
.movePointerTo([0,0])
.polarLine(r-n, 10)
.movePointerTo([0,0])
.polarLine(r, 20)
.moveBack() // that also would be helpful
I am not 100% keen on tagging / saving the position
There is something to be taken from tags. But that's a sidenote rather. https://youtu.be/aoxBIEbUggA?si=uA0c8JuZk8r44qvf&t=261
https://zoo.dev/docs/kcl-book/tags.html?highlight=tag#tagging-edges
You now have dogbone custom corners. I have tested them, but there might be some bugs lurking around.
Note that I have passed more corners - these are easier than dogbones to do with simple math.
Is there a technical reason behind? We could (I think) otherwise draw some interesting shapes:
With drawing you try to create closed shapes - so moving the points would be an issue (also a moveBack).
I am thinking of building something a bit different - a way to create a set of points you can place (and potentially constrain). You could then reference these points when drawing.
This would offer you the freedom that you need (i.e. placing stuff) without having to handle the edge cases introduced by (potentially complex) line geometry.
This is cool, for some reason I haven't even thought about arbitrary shapes, it was all squares in my mind. I think the issue might be closed and it's more appropriate to have separate general discussion about drawing api. You have some vision how the API should look like, there are interesting ideas in issues (like integrating solverspace).
The project is brilliant, it opens 3d modeling to people who didn't even think they could do that and I think it's one trending yt video of some js-dev blogger away from explosive adoption growth. Thanks for your work!