fix: duplicate shapes without position offset

This commit is contained in:
Formsmith746
2026-08-30 08:29:37 +03:00
parent 34528e6393
commit 62502b7e35
2 changed files with 5 additions and 8 deletions
@@ -7083,14 +7083,7 @@ export function SketchForgeEditor({
setNotice("Select a shape first");
return;
}
const duplicates = selectedShapes.map((shape) => {
const duplicate = cloneWorkplaneShapeTreeWithFreshIds(shape, "copy");
return {
...duplicate,
x: Math.min(110, shape.x + 8),
z: Math.min(110, shape.z + 8),
};
});
const duplicates = selectedShapes.map((shape) => cloneWorkplaneShapeTreeWithFreshIds(shape, "copy"));
commitShapes([...shapes, ...duplicates], duplicates.map((shape) => shape.id), `Duplicated ${duplicates.length} shape${duplicates.length === 1 ? "" : "s"}`);
}, [commitShapes, hasSelection, selectedShapes, shapes]);
+4
View File
@@ -157,6 +157,9 @@ describe("workplane shape helpers", () => {
const original = shape({
id: "outer-group",
kind: "mesh",
x: 14,
z: -9,
elevation: 3,
groupedShapes: [
shape({ id: "round-roof-child", kind: "roundRoof" }),
shape({
@@ -177,6 +180,7 @@ describe("workplane shape helpers", () => {
expect(new Set(duplicateIds).size).toBe(duplicateIds.length);
expect(duplicateIds.every((id) => !originalIds.includes(id))).toBe(true);
expect(duplicate).toMatchObject({ x: 14, z: -9, elevation: 3 });
expect(original.groupedShapes?.[0].id).toBe("round-roof-child");
expect(duplicate.groupedShapes?.[0].kind).toBe("roundRoof");
});