Closed JonnyHaystack closed 11 months ago
Related to Issue #83
This turns out to be a surprisingly difficult problem to solve due to the structure of the code. Joints are defined in the low level topology.py module where there is no knowledge of the builders. Changing the code structure isn't easy as import loops get generated; however, somehow this needs to be improved.
Completed with commit 63340c1b7d77c678f043b9fcaf974d48805c5529 Joints can be added within a BuildPart scope without specifying the to_part
parameter and don't need to be at the end of the builder. When the builder exits it copies the joints to the part. The https://build123d.readthedocs.io/en/latest/joints.html section of the docs describes this new behaviour.
Would be cool to be able to add Joints within builders, rather than having to do it afterwards.
For example, instead of the following
It would be nice if you could just declare the Joint inside a locations context in a builder, and have that added to the resulting part, something like this:
This example assumes a solution where each value in the
joints
dict is a list of Joints, or something like aJointList
, not a single Joint. Maybe someone can think of a better way, that's just the idea that I had off the top of my head. I think this could make it easier to read builder code using joints because the joints would be localised to the part of the model code that the joint is actually associated with, and it also would reduce the need to save Locations inside builder/location contexts and then iterate over those locations them outside, as is done in the first example.