cadquery
Sketch
Workplane
Assembly

Assembly.solve()

The Assembly.solve() function is a method of the Assembly class in the cadquery library, which is used to solve an assembly and generate a single solid body. This function is typically used after the components of the assembly have been defined and positioned relative to each other.

Syntax

The syntax for Assembly.solve() is:

Assembly.solve()

Parameters

This function does not accept any parameters.

Return value

This function returns a single solid body that represents the solved assembly.

Examples

Here is an example of using Assembly.solve():

import cadquery as cq

# Define a component
box = cq.Workplane().box(1, 1, 1).tag("box")

# Define an assembly
assembly = cq.Assembly().add(box).add(box.copy().rotate((0, 0, 45)))

# Solve the assembly
result = assembly.solve()

In this example, a cube-shaped component is defined, and then two instances of this component are added to an assembly, with one of them rotated by 45 degrees around the Z-axis. The Assembly.solve() function is then called to generate a single solid body from the assembled components.

Notes

  • The components of an assembly can be positioned and manipulated using methods such as translate(), rotate(), and mate().
  • A component can be added to an assembly using the add() method of the Assembly class.
  • The Assembly() class is a subclass of the Compound() class, so an Assembly object can be treated like a Compound object and also has access to all the methods of the Compound class.