Fix: IPC handlers now convert inch units to mm for position commands (#158)
The _ipc_move_component and _ipc_place_component handlers were ignoring the unit field from position parameters, always treating values as mm. When inches were specified, components would be placed at 1/25.4th of the intended position. Now reads the unit field and converts to mm before passing to the IPC backend. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5003,10 +5003,16 @@ print("ok")
|
||||
position = params.get("position", {})
|
||||
x = position.get("x", 0) if isinstance(position, dict) else params.get("x", 0)
|
||||
y = position.get("y", 0) if isinstance(position, dict) else params.get("y", 0)
|
||||
unit = position.get("unit", "mm") if isinstance(position, dict) else "mm"
|
||||
rotation = params.get("rotation", 0)
|
||||
layer = params.get("layer", "F.Cu")
|
||||
value = params.get("value", "")
|
||||
|
||||
# Convert inches to mm since ipc_backend expects mm
|
||||
if unit == "inch":
|
||||
x = x * 25.4
|
||||
y = y * 25.4
|
||||
|
||||
success = self.ipc_board_api.place_component(
|
||||
reference=reference,
|
||||
footprint=footprint,
|
||||
@@ -5043,8 +5049,14 @@ print("ok")
|
||||
position = params.get("position", {})
|
||||
x = position.get("x", 0) if isinstance(position, dict) else params.get("x", 0)
|
||||
y = position.get("y", 0) if isinstance(position, dict) else params.get("y", 0)
|
||||
unit = position.get("unit", "mm") if isinstance(position, dict) else "mm"
|
||||
rotation = params.get("rotation")
|
||||
|
||||
# Convert inches to mm since ipc_backend.move_component expects mm
|
||||
if unit == "inch":
|
||||
x = x * 25.4
|
||||
y = y * 25.4
|
||||
|
||||
success = self.ipc_board_api.move_component(
|
||||
reference=reference, x=x, y=y, rotation=rotation
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user