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.
-
Method
mate
: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:
from collections import OrderedDict as odict hexapod = 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
-
Visualize mates in CQ-Editor (Note:
show_mates
needsshow_object
as parameter andlength
determines the size of the visualised mate)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
show(hexapod, render_mates=True)
-
Method
assemble
def assemble(self, object_name: str, target: Union[str, Location]) -> Optional["MAssembly"]:
-
Example
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
pip install git+https://github.com/bernhard-42/cadquery-massembly
Details see jupyter-cadquery
Jupyter CadQuery additionally supports animating the object