Repository navigation
feat: position workpieces relative to a chosen origin - #587
Conversation
Workpieces can now choose which local point their X/Y position refers to and which point stays fixed when they are resized or regenerated: the bounding box corner (default), the box center, or the geometry provider's reference point. Geometry providers declare their reference point via the new get_reference_point() on the IGeometryProvider protocol; sketches report their fixed origin. Both regeneration paths -- parameter changes and sketch edits (UpdateAssetCommand) -- resize around the anchor and re-position, so the origin of a parametric sketch stays registered when its geometry changes. The properties panel gains a 'Position relative to' selector for single workpieces; the X/Y rows then refer to the chosen point. The screenshotter gains a main:item-properties target that captures the panel, and the positioning docs embed it in all languages. Note for addon authors: geometry providers must now implement get_reference_point(); the protocol default returns None, so inheriting providers need no change, but structural implementations have to add the method to keep passing the runtime isinstance checks.
🤖 Estimated LLM implementation costReplayed each of the 1 commits in this pull request and counted the code lines each commit added or rewrote:
Added lines by language: Python 547, Markdown 281 Full estimate
Cost model: ≈10 tokens per code line at $15/Mtok output and $3/Mtok input (assuming heavy prompt caching); input ≈ 15× output for conversation replay; a review round ≈ 42,000 tokens; a failed CI run ≈ 21,000 tokens; file reads capped at 20 kB each. Active window from first commit to merge: <1 day.
|
Summary
Workpieces can now choose which local point their X/Y position refers to and which point stays fixed when they are resized or regenerated:
The properties panel gains a Position relative to selector for single workpieces, and the X/Y rows then show and set the chosen point's position — so X=0/Y=0 places the sketch origin at the machine/WCS origin.
Motivation
Parametric sketches previously drifted whenever their parameters changed: geometry was normalized to the bounding box corner, and regeneration preserved the box center. With both cut- and engrave sketches constrained around the sketch origin and positioned via the reference point, they stay registered to each other across any parameter change.
Details
IGeometryProvidergainsget_reference_point()(defaultNone);Sketchreports its fixed origin point.WorkPiece.anchor_mode(serialized) selects the anchor; regeneration resizes around the anchor and re-positions so it stays at its world position. Both regeneration paths honor it: parameter overrides (regenerate_from_geometry_provider) and sketch edits (UpdateAssetCommand).DocItem.set_size()accepts ananchorparameter (local point to keep in place); the anchor lifecycle itself stays inWorkPiece.main:item-propertiestarget (properties panel only, no full window), and the positioning docs embed the new screenshot in all languages.Note for addon authors: providers must now implement
get_reference_point(). The protocol default returnsNone, so providers inheritingIGeometryProviderneed no change — but structural (duck-typed) implementations must add the method to keep passing the runtimeisinstancechecks.Testing
set_sizeanchor preservation, serialization round-trip, and regeneration keeping corner/center/reference fixed (including the asymmetric-bbox case).UpdateAssetCommand) keeps the reference anchor fixed.pixi run lintclean; targeted suites pass (tests/core,tests/doceditor, sketcher and laser step tests).