Manual assembly system enhancement
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 541
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 5
Description
@adam-urbanczyk @jmwright
We discussed the topic of nested assemblies in https://github.com/CadQuery/cadquery/issues/522 and I think since you started to merge https://github.com/CadQuery/cadquery/pull/538 this will be part of the next release.
I thought it might be easier no to open a new issue to discuss the manual assemblies I introduced in https://github.com/CadQuery/cadquery/issues/522
I took your door tutorial (added "door" as the name to the top level hierarchy to not have to deal with uuids) and used my manual approach to assemble it:
```python
from collections import OrderedDict as odict
# add mates to the ends of the vslots
for v in ["bottom", "left", "top", "right"]:
door.mate(f"door/{v}@faces@>Z", name=f"{v}_0", transforms=odict(rx=180))
door.mate(f"door/{v}@faces@X[-4]", name="panel_1")
# add mates to handle and one hole
door.mate("door/handle?mate1", name="handle_0")
door.mate("door/panel?hole1", name="handle_1", transforms=odict(rz=-90))
```
For better visibility I have spread the objects:

Given these mates, one can now assemble the door like one would do it in reality:
```python
door.assemble("bottom_0", "con_bl_0") # add bottom vslot to bottom-left connector
door.assemble("con_br_1", "bottom_1") # add bottom-right connector to bottom vslot
door.assemble("left_1", "con_bl_1") # add left vslot to bottom-left connector
door.assemble("right_0", "con_br_0") # add right vslot to bottom-right connector
door.assemble("panel_0", "panel_1") # add panel
door.assemble("con_tl_0", "left_0") # add top-left connector to left vslot
door.assemble("con_tr_1", "right_1") # add top-right connector to right vslot
door.assemble("top_1", "con_tl_1") # add top vslot to top-left connector
door.assemble("handle_0", "handle_1") # add handle
```
By the way, since I don't want to use Threejs animation system, `there` is no need to relocate the objects.
Full code can be found [here](https://github.com/bernhard-42/jupyter-cadquery/blob/master/examples/assemblies/5-door.ipynb)
Would you be interested in a pull request? It would be the file [mate.py](https://github.com/bernhard-42/jupyter-cadquery/blob/master/jupyter_cadquery/mate_assembly/mate.py) and the methods
- `mate`
- `_relocate`
- `relocate`
- `assemble`
from [massembly.py](https://github.com/bernhard-42/jupyter-cadquery/blob/master/jupyter_cadquery/mate_assembly/massembly.py) plus two properties: `mates` and `_origin_mate`
The methods `mate` and `assemble` are the core methods used in the example above. Of course, one could combine `mate` and `assemble` so that `assemble` gets both mate definitions, however, for me it has proven helpful to split these steps to visually analyse the mates (location and orientation) before doing the final assembly
Note: `_origin_mate` plus `_relocate` and `relocate` are only needed to shift the objects in space to allow the hierarchical threejs system to rotate/translate appropriately.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.