Positioning and orientation
Which one do I use?
These APIs all affect where something ends up, but they mean different things. Choose the one that matches the rule in the model.
| You want to… | Use | What it means |
|---|---|---|
| Place or align geometry inside one part | shape.at(...) | Geometric placement. No joint or assembly relationship is created. |
| Put a feature on a face of another shape | feature.on(...) | Within-part feature placement. The selected Faces value chooses the support or entry face. |
| Place a feature with explicit parent/child anchors | Shape.attach(...) | Lower-level within-part feature anchoring. Prefer on() when a simple face is enough. |
| Give one component occurrence an absolute pose | Placement(...) | Position and optional orientation at occurrence creation/copy time. No joint is created. |
| Relate two separate physical component occurrences | Occurrence.attach(...) | An assembly relationship that SolidCraft stores as a native joint. |
The important distinction:Shape.attach() and Occurrence.attach() have the same verb but work at different levels. The first places a feature inside one part. The second relates two separate component occurrences.
Start with the coordinate system
X, Y and Z are model axes. A normal Box has its large base in XY and thickness along Z. A camera rotation changes only the view. It does not change the model coordinates.
Also separate two levels: geometry inside one part has its own coordinates; a component occurrence has a pose in the assembly.
Use at() to place or align geometry
from scpf import Anchor, Axis, Box, Cylinder
pin = Cylinder(d=8, h=20, axis=Axis.X).at(
10, 0, 5,
anchor=Anchor.LEFT,
)
body = Box(80, 50, 12)
centered_bore = Cylinder(d=8, h=30, axis=Axis.X).at(body)shape.at(x, y, z) places supported geometry at an absolute model coordinate. A primitive can use anchor=... to say which of its own datums belongs at that coordinate.
shape.at(target) currently aligns CENTER to CENTER. It does not mean “put this on the top face”. For a feature on a face, use on().
Use on() for a feature on a face
from scpf import Box, Depth, Faces, Hole
plate = Box(100, 60, 10)
hole = Hole(d=8, depth=Depth.THROUGH_ALL).on(
plate,
face=Faces.TOP,
offset=(20, 0),
)
plate = plate + holeon() is for a feature that belongs to an existing shape. Faces.TOP or Faces.BOTTOM selects the face where the feature starts or is supported. The offset is measured in that face.
A sketch has the same idea in explicit form: Sketch(on=body, parent=Anchor.TOP) creates a named sketch on a selected body face.
Shape.attach() is lower-level within-part placement
from scpf import Anchor, Boss, X, Y
boss = Boss(d=7, h=12, hole_d=2.5).attach(
case,
parent=Anchor.INNER_BOTTOM,
offset=(X.MIN + 10, Y.MAX - 10),
)Use Shape.attach() only when a simple on() face does not express the required feature reference. It lets you choose explicit parent and child anchors.
This does not create an assembly joint. The feature and target are still geometry inside one part.
Use Placement for a component occurrence
from scpf import Placement, X, Z, component
@component
class Panel:
def build(self):
return Box(160, 320, 14.5)
first = Panel()
second = first.copy(
placement=Placement(x=160, z=20)
)
upright = first.copy(
placement=Placement(
z=160,
rotation=(X, 90),
)
)
upside_down = first.copy(
placement=Placement(rotation=(Z, 180))
)Placement describes the complete pose of one component occurrence in its parent coordinate frame. XYZ is absolute. The optional rotation is one axis-angle orientation.
Placement does not say that one component depends on another. It only says where this occurrence is.
Use Occurrence.attach() for separate physical parts
from scpf import Anchor
left = Block()
right = Block().attach(
left,
parent=Anchor.RIGHT,
child=Anchor.LEFT,
)
assembly = left + rightHere right is a separate physical part. Its rule is not an absolute XYZ position; its left side belongs on the right side of left. That is an assembly relationship, so use Occurrence.attach().
SolidCraft stores this as a native joint. If the parent changes size, the relationship can still express which references belong together. The next chapter, From one component to an assembly, builds on this distinction.
Shape.move() is a local geometry translation
body = Box(40, 20, 10)
shifted = body.move(x=10, y=0, z=25)move() translates supported geometry inside its current shape expression. It is not the normal way to position a component occurrence. Use Placement for occurrences.
Copies can have different placements
first = Panel(
placement=Placement(z=160, rotation=(X, 90))
)
second = first.copy(
placement=Placement(x=160, z=160, rotation=(X, 90))
)
screen = first + secondThe two occurrences reuse one component definition but have different placements. copy() without a placement override keeps the source Placement.
Current limits
| Operation | Current meaning |
|---|---|
Shape.at(...) | Absolute geometry placement; shape-to-shape alignment is currently CENTER-to-CENTER. |
Shape.on(...) | Supported within-part feature placement on TOP or BOTTOM. |
Shape.attach(...) | Lower-level within-part feature anchoring. |
Placement(...) | Absolute occurrence pose with one optional axis-angle rotation. |
Occurrence.attach(...) | Assembly relationship between separate component occurrences. |