Build123d's algebra mode works on objects of the classes Shape, Part, Sketch and Curve and is based on two concepts:
- Object arithmetic
- Placement arithmetic
Creating a box and a cylinder centered at
(0, 0, 0)b = Box(1, 2, 3) c = Cylinder(0.2, 5)
Fusing a box and a cylinder
r = Box(1, 2, 3) + Cylinder(0.2, 5)
Cutting a cylinder from a box
r = Box(1, 2, 3) - Cylinder(0.2, 5)
Intersecting a box and a cylinder
r = Box(1, 2, 3) & Cylinder(0.2, 5)
Notes:
- b, c and r are instances of class
Compoundand can be viewed with every viewer that can showbuild123d.Compoundobjects. - A discussion around performance can be found in :ref:`algebra_performance`.
- A mathematically formal definition of the algebra can be found in :ref:`algebra_definition`.
A Part, Sketch or Curve does not have any location or rotation parameter.
The rationale is that an object defines its topology (shape, sizes and its center), but does not know
where in space it will be located. Instead, it will be relocated with the * operator onto a plane
and to location relative to the plane (similar moved).
The generic forms of object placement are:
Placement on
planeor atlocationrelative to XY plane:plane * alg_compound location * alg_compound
2. Placement on the plane and then moved relative to the plane by location
(the location is relative to the local coordinate system of the plane).
plane * location * alg_compound
Details can be found in :ref:`location_arithmetics`.
Examples:
Box on the
XYplane, centered at (0, 0, 0) (both forms are equivalent):Plane.XY * Box(1, 2, 3) Box(1, 2, 3)
Note: On the
XYplane no placement is needed (mathematicallyPlane.XY *will not change the location of an object).Box on the
XYplane centered at (0, 1, 0) (all three are equivalent):Plane.XY * Pos(0, 1, 0) * Box(1, 2, 3) Pos(0, 1, 0) * Box(1, 2, 3) Pos(Y=1) * Box(1, 2, 3)
Note: Again,
Plane.XYcan be omitted.Box on plane
Plane.XZ:Plane.XZ * Box(1, 2, 3)
Box on plane
Plane.XZwith a location(X=1, Y=2, Z=3)relative to theXZplane, i.e., using the x-, y- and z-axis of theXZplane:Plane.XZ * Pos(1, 2, 3) * Box(1, 2, 3)
Box on plane
Plane.XZmoved to(X=1, Y=2, Z=3)relative to this plane and rotated there by the angles (X=0, Y=100, Z=45) aroundPlane.XZaxes:Plane.XZ * Pos(1, 2, 3) * Rot(0, 100, 45) * Box(1, 2, 3) Location((1, 2, 3), (0, 100, 45)) * Box(1, 2, 3)
Note:
Pos * Rotis the same as usingLocationdirectlyBox on plane
Plane.XZrotated on this plane by the angles(X=0, Y=100, Z=45)(using the x-, y- and z-axis of theXZplane) and then moved to(X=1, Y=2, Z=3)relative to theXZplane:Plane.XZ * Rot(0, 100, 45) * Pos(0,1,2) * Box(1, 2, 3)
Object arithmetic and Placement at locations can be combined:
b = Plane.XZ * Rot(X=30) * Box(1, 2, 3) + Plane.YZ * Pos(X=-1) * Cylinder(0.2, 5)
Note: In Python * binds stronger then +, -, &, hence brackets are not needed.