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.
The syntax for Assembly.solve()
is:
Assembly.solve()
This function does not accept any parameters.
This function returns a single solid body that represents the solved assembly.
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.
translate()
, rotate()
, and mate()
.add()
method of the Assembly
class.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.