The Assembly()
method in cadquery
allows the creation of complex 3D assemblies by merging multiple parts together.
Assembly(name=None, move=None, rotate=None)
name
(optional): A string representing the name of the assembly. If not specified, a default name will be used.move
(optional): A tuple representing the displacement of the assembly in (x, y, z) directions. If not specified, the assembly will be at the origin.rotate
(optional): A tuple representing the rotation angles around (x, y, z) axes in degrees. If not specified, the assembly will not be rotated.A new Assembly
object.
import cadquery as cq
# Create two cubes
c1 = cq.Workplane().box(1, 1, 1)
c2 = cq.Workplane().box(1, 1, 1)
# Create an assembly and add the cubes to it
assembly = cq.Assembly()
assembly.add(c1)
assembly.add(c2)
# Export the assembly as an STL file
cq.exporters.export(assembly, "assembly.stl")
import cadquery as cq
# Create two cubes
c1 = cq.Workplane().box(1, 1, 1)
c2 = cq.Workplane().box(1, 1, 1)
# Create an assembly and add the cubes to it
assembly = cq.Assembly()
assembly.add(c1)
assembly.add(c2)
# Move the assembly 5 units in the x direction and rotate it
assembly = assembly.rotate((0, 0, 0), (0, 0, 90))
assembly = assembly.translate((5, 0, 0))
# Export the assembly as an STL file
cq.exporters.export(assembly, "assembly.stl")
Assembly
objects are mutable, so you can add or remove parts from them.