https://github.com/bernhard-42/cadquery-massembly
A manual assembly system based on mates
https://github.com/bernhard-42/cadquery-massembly
Last synced: about 2 months ago
JSON representation
A manual assembly system based on mates
- Host: GitHub
- URL: https://github.com/bernhard-42/cadquery-massembly
- Owner: bernhard-42
- License: bsd-3-clause
- Created: 2021-01-06T18:37:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T16:28:38.000Z (almost 3 years ago)
- Last Synced: 2025-07-11T19:48:05.944Z (3 months ago)
- Language: Python
- Size: 4.36 MB
- Stars: 18
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# MAssembly for *CadQuery*
## Intro
CadQuery provides numerical solver based assemblies.
`MAssembly` is derived from `cadquery.Assembly`, however, allows to define mates which will be used to manually assemble the objects.
### Mate definitions
- Method `mate`:
```python
def mate(
self, query: str, name: str, origin: bool = False, transforms: Union[Dict, OrderedDict] = None
) -> "MAssembly":def mate(
self, id: str, mate: Mate, name: str, origin: bool = False, transforms: Union[Dict, OrderedDict] = None
) -> "MAssembly":
```- Example:
```python
from collections import OrderedDict as odicthexapod = create_hexapod()
hexapod.mate("bottom?top", name="bottom", origin=True)
hexapod.mate(
"top?bottom", name="top", origin=True, transforms=odict(rx=180, tz=-(height + 2 * tol))
)
```Full code see [2-hexapod.py](./examples/cq-editor/2-hexapod.py)
### Mate visualisation
- Visualize mates in CQ-Editor (Note: `show_mates` needs `show_object`as parameter and `length`determines the size of the visualised mate)
```python
from cadquery_massembly.cq_editor import show_mates
show_object(hexapod, name="hexapod")
show_mates(hexapod, show_object, length=5)
```- Visualize mates in Jupyter CadQuery
```python
show(hexapod, render_mates=True)
```### Final assembly
- Method `assemble`
```python
def assemble(self, object_name: str, target: Union[str, Location]) -> Optional["MAssembly"]:
```- Example
```python
check_mates = False
if check_mates:
show_object(hexapod, name="hexapod")
show_mates(hexapod, show_object, length=5)
else:
# Assemble the parts
for leg in leg_names:
hexapod.assemble(f"leg_{leg}_lower_hole", f"leg_{leg}_hole")
hexapod.assemble(f"leg_{leg}_hinge", f"{leg}_hole")
# ...show_object(hexapod, name="hexapod")
```Full code see [2-hexapod.py](./examples/cq-editor/2-hexapod.py)
## Installation
```shell
pip install git+https://github.com/bernhard-42/cadquery-massembly
```## Visualisation
### CQ-Editor
- Check mates view (`check_mates = True`)

- Assembled view (`check_mates = False`)

### Jupyter Cadquery
Details see [jupyter-cadquery](https://github.com/bernhard-42/jupyter-cadquery)
- Check mates view
- Assembled view

Jupyter CadQuery additionally supports animating the object
