@floless/app 0.135.1 → 0.137.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +634 -274
- package/dist/schemas/steel.model.v2.schema.json +18 -17
- package/dist/skills/floless-app-report-issue/SKILL.md +46 -9
- package/dist/skills/floless-app-steel-model/SKILL.md +13 -12
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +61 -65
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +119 -0
- package/dist/templates/steel-model.flo +44 -4
- package/dist/web/commands-steel.js +6 -0
- package/dist/web/instructor.js +1 -0
- package/dist/web/steel-editor.html +609 -56
- package/dist/web/steel-model-v2-client-validation.js +36 -17
- package/dist/web/steel-model-v2-commands.js +82 -86
- package/dist/web/steel-model-v2-projection.js +179 -22
- package/dist/web/steel-plan-transform.js +82 -29
- package/dist/web/steel-plan-view-id.js +140 -0
- package/dist/web/steel-view-generation.js +2 -1
- package/dist/web/workspaces.js +7 -2
- package/package.json +2 -1
|
@@ -12,8 +12,9 @@ import { validateSchemaSubset } from './json-schema-subset.js';
|
|
|
12
12
|
* `$defs` (e.g. `{...schema.$defs.dim3, $defs: schema.$defs}`) so local `$ref`s still resolve.
|
|
13
13
|
*/
|
|
14
14
|
export { validateSchemaSubset };
|
|
15
|
-
import {
|
|
15
|
+
import { parseSpacings } from './grid-core.js';
|
|
16
16
|
import { positionBasisIssue,POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
|
|
17
|
+
import { rawPlanViewId } from './steel-plan-view-id.js';
|
|
17
18
|
export const POSITION_BASIS_CLIENT_VALIDATION_VERSION=POSITION_BASIS_CAPABILITY_VERSION;
|
|
18
19
|
|
|
19
20
|
const rows = (v) => Array.isArray(v) ? v : [];
|
|
@@ -33,23 +34,32 @@ export function validateClientSteelModelV2(doc, schema) {
|
|
|
33
34
|
for (const [id, count] of memberCounts) if (!id || count !== 1) issues.push(`member-id-${id ? 'duplicate' : 'empty'} at $.members`);
|
|
34
35
|
|
|
35
36
|
const plans = rows(doc.plans);
|
|
36
|
-
const
|
|
37
|
+
const viewIds = new Map();
|
|
38
|
+
// Counted up front so EVERY colliding row is named, not just the ones after the first — a report that
|
|
39
|
+
// says "$.plans[3]" and nothing else leaves the author guessing which other row it collides with.
|
|
40
|
+
for (const plan of plans) {
|
|
41
|
+
const id = rawPlanViewId(plan);
|
|
42
|
+
if (id !== null) viewIds.set(id, (viewIds.get(id) || 0) + 1);
|
|
43
|
+
}
|
|
37
44
|
const presented = new Set();
|
|
38
45
|
const axes = rows(doc.grid?.axes);
|
|
39
46
|
const axisIds = new Set();
|
|
47
|
+
const axisDir = new Map();
|
|
40
48
|
for (const axis of axes) {
|
|
41
49
|
if (!axis?.id || axisIds.has(axis.id)) issues.push(`grid-axis-id-duplicate at $.grid.axes`);
|
|
42
50
|
axisIds.add(axis?.id);
|
|
51
|
+
if (axis?.id && axis?.dir) axisDir.set(axis.id, axis.dir);
|
|
43
52
|
}
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
// `grid-axis-count`: the axis rows must pair one-for-one with the parsed spacings.
|
|
54
|
+
//
|
|
55
|
+
// This used to also build a per-direction LABEL COUNT, because a registration control was resolved by
|
|
56
|
+
// label and a name that occurred twice — or zero times — had to refuse. Registration now resolves
|
|
57
|
+
// stable axis IDS (#935), so the counting is gone and only the pairing check remains; the label
|
|
58
|
+
// resolver keeps its own job of deciding what a bubble PRINTS (#740).
|
|
59
|
+
const checkAxisCount = (dir) => {
|
|
60
|
+
if (!object(doc.grid)) return;
|
|
51
61
|
const spacings = parseSpacings(dir === 'x' ? doc.grid.x : doc.grid.y);
|
|
52
|
-
if (spacings.err) return
|
|
62
|
+
if (spacings.err) return;
|
|
53
63
|
const n = spacings.offsets.length;
|
|
54
64
|
// The axes must pair with the parsed spacings, and this is where that becomes checkable in the
|
|
55
65
|
// browser. Say it directly rather than leaving it to be inferred from an unresolved control: with the
|
|
@@ -67,23 +77,32 @@ export function validateClientSteelModelV2(doc, schema) {
|
|
|
67
77
|
// they get now. (Codex review, #918.)
|
|
68
78
|
const declared = axes.filter((a) => object(a) && a.dir === dir).length;
|
|
69
79
|
if (declared !== n) issues.push(`grid-axis-count at $.grid.axes — $.grid.${dir} parses to ${n} ${dir} ${n === 1 ? 'entry' : 'entries'} but $.grid.axes declares ${declared} ${dir} ${declared === 1 ? 'axis' : 'axes'}`);
|
|
70
|
-
for (const label of axisLabelsFor(doc.grid, dir, style, n)) counts.set(label, (counts.get(label) || 0) + 1);
|
|
71
|
-
return counts;
|
|
72
80
|
};
|
|
73
|
-
|
|
81
|
+
checkAxisCount('x');
|
|
82
|
+
checkAxisCount('y');
|
|
74
83
|
const axisRef = (id, path) => {
|
|
75
84
|
if (id && !axisIds.has(id)) issues.push(`grid-axis-unresolved at ${path}`);
|
|
76
85
|
};
|
|
86
|
+
// Registration resolves against stable axis IDS, never the editable display label (#935). Direction
|
|
87
|
+
// is part of the check: `xAxisId` naming a dir-y axis is a transposition, not a lookup miss.
|
|
77
88
|
const controlRef = (ref, path) => {
|
|
78
89
|
if (!ref) return;
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
for (const [field, want] of [['xAxisId', 'x'], ['yAxisId', 'y']]) {
|
|
91
|
+
const id = ref[field];
|
|
92
|
+
if (!id || !axisIds.has(id)) issues.push(`control-ref-unresolved at ${path}.${field}`);
|
|
93
|
+
else if (axisDir.get(id) !== want) issues.push(`control-ref-direction at ${path}.${field}`);
|
|
81
94
|
}
|
|
82
95
|
};
|
|
83
96
|
for (let pi = 0; pi < plans.length; pi += 1) {
|
|
84
97
|
const plan = plans[pi];
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
/*
|
|
99
|
+
* A row is one drawing VIEW, identified by its resolved view id (#938). Two views may share a
|
|
100
|
+
* physical page — five elevations on one sheet — but never an id. Server parity:
|
|
101
|
+
* `plan-view-id-duplicate` in `steel-model-v2.ts`, which replaced `plan-sheet-duplicate` because
|
|
102
|
+
* two unnamed rows on one page collide on IDENTITY, not on the page.
|
|
103
|
+
*/
|
|
104
|
+
const viewId = rawPlanViewId(plan);
|
|
105
|
+
if (viewId !== null && (viewIds.get(viewId) ?? 0) > 1) issues.push(`plan-view-id-duplicate at $.plans[${pi}]`);
|
|
87
106
|
controlRef(plan.datum_ref, `$.plans[${pi}].datum_ref`);
|
|
88
107
|
controlRef(plan.control2_ref, `$.plans[${pi}].control2_ref`);
|
|
89
108
|
for (const id of rows(plan.memberRefs)) {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* This module is inert until steel-editor.html creates a session and hands it tagged projection objects.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { planViewId } from './steel-plan-view-id.js';
|
|
13
14
|
import { sheetPxToWorld, worldToSheetPx } from './steel-plan-transform.js';
|
|
14
15
|
import { memberPresence, projectionLink } from './steel-model-v2-projection.js';
|
|
15
16
|
import { axisLabelsFor, gridLabelPatch, parseSpacings } from './grid-core.js';
|
|
@@ -73,9 +74,15 @@ export class V2CommandError extends Error {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
/**
|
|
78
|
+
* The row this command acts on, resolved by VIEW ID (#938).
|
|
79
|
+
*
|
|
80
|
+
* Was `p.sheet === sheet`, which returned the first row on a page. Five elevations on one page would
|
|
81
|
+
* therefore all have been edited through whichever came first, at that row's registration and scale.
|
|
82
|
+
*/
|
|
83
|
+
function planByViewId(doc, viewId) {
|
|
84
|
+
const plan = (doc.plans || []).find((p) => planViewId(p) === viewId);
|
|
85
|
+
if (!plan) throw new V2CommandError('view-unresolved', `drawing view "${viewId}" does not exist`);
|
|
79
86
|
return plan;
|
|
80
87
|
}
|
|
81
88
|
|
|
@@ -432,9 +439,11 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
432
439
|
return session.transact('restore undo snapshot', (draft) => {
|
|
433
440
|
draft.members = Array.isArray(saved.members) ? clone(saved.members) : [];
|
|
434
441
|
draft.grid = Object.hasOwn(saved, 'grid') ? clone(saved.grid) : null;
|
|
435
|
-
|
|
442
|
+
// Keyed by VIEW ID, not page (#938): with two views on one sheet a page-keyed map holds one of
|
|
443
|
+
// them, and every sibling would be restored from its neighbour's dims, refs and observations.
|
|
444
|
+
const byView = new Map((saved.plans || []).map((plan) => [planViewId(plan), plan]));
|
|
436
445
|
for (const plan of draft.plans || []) {
|
|
437
|
-
const row =
|
|
446
|
+
const row = byView.get(planViewId(plan));
|
|
438
447
|
if (!row) continue;
|
|
439
448
|
plan.dims = clone(row.dims || []);
|
|
440
449
|
plan.memberRefs = clone(row.memberRefs || []);
|
|
@@ -504,12 +513,12 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
504
513
|
});
|
|
505
514
|
},
|
|
506
515
|
|
|
507
|
-
setEndpointPx(
|
|
516
|
+
setEndpointPx(viewId, memberId, index, point) {
|
|
508
517
|
return session.transact('set endpoint', (doc) => {
|
|
509
518
|
const member = memberById(doc, memberId);
|
|
510
519
|
const old = endpoint(member, index);
|
|
511
520
|
setEndpoint(member, index, sheetPxToWorld(point, {
|
|
512
|
-
...
|
|
521
|
+
...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid,
|
|
513
522
|
}, clone(old.z)));
|
|
514
523
|
return { changedIds: [memberId] };
|
|
515
524
|
});
|
|
@@ -605,11 +614,11 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
605
614
|
});
|
|
606
615
|
},
|
|
607
616
|
|
|
608
|
-
addMemberPx(
|
|
617
|
+
addMemberPx(viewId, projected) {
|
|
609
618
|
return session.transact('add member', (doc) => {
|
|
610
619
|
const id = projected.id && !(doc.members || []).some((m) => m.id === projected.id)
|
|
611
620
|
? projected.id : mintId();
|
|
612
|
-
const plan = { ...
|
|
621
|
+
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid };
|
|
613
622
|
const fromZ = projected.role === 'column' ? projected.col?.bos : projected.ends?.[0]?.tos;
|
|
614
623
|
const toZ = projected.role === 'column' ? projected.col?.tos : projected.ends?.[1]?.tos;
|
|
615
624
|
const from = sheetPxToWorld(projected.wp[0], plan,
|
|
@@ -631,25 +640,25 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
631
640
|
});
|
|
632
641
|
}
|
|
633
642
|
doc.members.push(member);
|
|
634
|
-
const canonicalPlan =
|
|
643
|
+
const canonicalPlan = planByViewId(doc, viewId);
|
|
635
644
|
canonicalPlan.memberRefs = [...new Set([...(canonicalPlan.memberRefs || []), id])];
|
|
636
645
|
return { changedIds: [id], structural: true, value: id };
|
|
637
646
|
});
|
|
638
647
|
},
|
|
639
648
|
|
|
640
|
-
setEndpointsPx(
|
|
649
|
+
setEndpointsPx(viewId, memberId, a, b) {
|
|
641
650
|
return session.transact('set endpoints', (doc) => {
|
|
642
651
|
const member = memberById(doc, memberId);
|
|
643
|
-
const plan = { ...
|
|
652
|
+
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid };
|
|
644
653
|
member.from = sheetPxToWorld(a, plan, clone(member.from.z));
|
|
645
654
|
member.to = sheetPxToWorld(b, plan, clone(member.to.z));
|
|
646
655
|
return { changedIds: [memberId] };
|
|
647
656
|
});
|
|
648
657
|
},
|
|
649
658
|
|
|
650
|
-
translatePx(
|
|
659
|
+
translatePx(viewId, ids, offset) {
|
|
651
660
|
return session.transact('translate members', (doc) => {
|
|
652
|
-
const plan = { ...
|
|
661
|
+
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid };
|
|
653
662
|
for (const id of ids) {
|
|
654
663
|
const member = memberById(doc, id);
|
|
655
664
|
const a = sheetPxToWorld(worldPoint(member.from, plan, offset), plan, clone(member.from.z));
|
|
@@ -713,9 +722,9 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
713
722
|
});
|
|
714
723
|
},
|
|
715
724
|
|
|
716
|
-
patchPlan(
|
|
725
|
+
patchPlan(viewId, patch) {
|
|
717
726
|
return session.transact('patch plan', (doc) => {
|
|
718
|
-
const plan =
|
|
727
|
+
const plan = planByViewId(doc, viewId);
|
|
719
728
|
for (const [key, value] of Object.entries(patch)) {
|
|
720
729
|
if (value === undefined) delete plan[key];
|
|
721
730
|
else plan[key] = key === 'dims' ? canonicalizeDimensionRefs(doc, value) : clone(value);
|
|
@@ -724,18 +733,18 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
724
733
|
});
|
|
725
734
|
},
|
|
726
735
|
|
|
727
|
-
addPlanDims(
|
|
736
|
+
addPlanDims(viewId, dims) {
|
|
728
737
|
return session.transact('add plan dimensions', (doc) => {
|
|
729
|
-
const plan =
|
|
738
|
+
const plan = planByViewId(doc, viewId);
|
|
730
739
|
plan.dims = [...(plan.dims || []), ...canonicalizeDimensionRefs(doc, dims)];
|
|
731
740
|
return { structural: true };
|
|
732
741
|
});
|
|
733
742
|
},
|
|
734
743
|
|
|
735
|
-
detachDimRefs(
|
|
744
|
+
detachDimRefs(viewId, ids) {
|
|
736
745
|
return session.transact('detach dimension references', (doc) => {
|
|
737
746
|
const selected = new Set(ids);
|
|
738
|
-
for (const dim of
|
|
747
|
+
for (const dim of planByViewId(doc, viewId).dims || []) {
|
|
739
748
|
for (const key of ['aRef', 'bRef']) if (selected.has(dim[key]?.m)) delete dim[key];
|
|
740
749
|
}
|
|
741
750
|
return { structural: true };
|
|
@@ -810,10 +819,10 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
810
819
|
return session.offsetElevation(memberId, Number(targetDefaultIn) - Number(sourceDefaultIn));
|
|
811
820
|
},
|
|
812
821
|
|
|
813
|
-
patchGrid(
|
|
822
|
+
patchGrid(viewId, patch) {
|
|
814
823
|
return session.transact('patch grid', (doc) => {
|
|
815
824
|
if (!doc.grid) throw new V2CommandError('grid-unavailable', 'the model has no grid');
|
|
816
|
-
const plan = { ...
|
|
825
|
+
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid };
|
|
817
826
|
for (const [key, value] of Object.entries(patch)) {
|
|
818
827
|
if (value === undefined) delete doc.grid[key];
|
|
819
828
|
else if (key === 'origin') {
|
|
@@ -828,47 +837,32 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
828
837
|
/**
|
|
829
838
|
* Rename one grid direction's axes — and carry the sheet registrations that named them.
|
|
830
839
|
*
|
|
831
|
-
* A registration control
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
840
|
+
* A registration control used to store a LABEL, so a rename that touched the grid alone would orphan
|
|
841
|
+
* every sheet registered on the old name and the validator would refuse the whole edit — and this
|
|
842
|
+
* command carried a slot-by-slot rewrite to chase each control onto its axis's new name (#740).
|
|
843
|
+
* That rewrite is GONE, because #935 moved registration onto stable axis ids: renaming a bubble is
|
|
844
|
+
* now purely a display edit and cannot reach a control at all. The bug it was written for cannot
|
|
845
|
+
* recur, and neither can the class it belonged to.
|
|
836
846
|
*
|
|
837
847
|
* `labels` is the full list for the direction in authored axis order, or null to clear it to auto.
|
|
838
848
|
*/
|
|
839
849
|
setGridLabels(dir, labels) {
|
|
840
850
|
return session.transact('rename grid axes', (doc) => {
|
|
841
851
|
if (!doc.grid) throw new V2CommandError('grid-unavailable', 'the model has no grid');
|
|
842
|
-
|
|
852
|
+
// Still parsed, and still refused on error: `gridLabelPatch` writes one label per parsed entry,
|
|
853
|
+
// so an unreadable spacing string would silently decide how many axes get renamed.
|
|
843
854
|
const spacings = parseSpacings(dir === 'x' ? doc.grid.x : doc.grid.y);
|
|
844
855
|
if (spacings.err) throw new V2CommandError('grid-spacing-invalid', `the model grid's ${dir} spacing is unreadable: ${spacings.err}`);
|
|
845
|
-
const n = spacings.offsets.length;
|
|
846
|
-
const before = axisLabelsFor(doc.grid, dir, style, n);
|
|
847
856
|
Object.assign(doc.grid, gridLabelPatch(doc.grid, dir, labels));
|
|
848
|
-
const after = axisLabelsFor(doc.grid, dir, style, n);
|
|
849
|
-
|
|
850
|
-
// Built COMPLETE before any control is rewritten, so a pair of axes that swap names is applied
|
|
851
|
-
// once each rather than chased around the map.
|
|
852
|
-
const moved = new Map();
|
|
853
|
-
before.forEach((old, i) => { if (after[i] !== old) moved.set(old, after[i]); });
|
|
854
|
-
if (moved.size) {
|
|
855
|
-
const key = dir === 'x' ? 'axis_x' : 'axis_y';
|
|
856
|
-
for (const plan of doc.plans || []) {
|
|
857
|
-
for (const refKey of ['datum_ref', 'control2_ref']) {
|
|
858
|
-
const ref = plan[refKey];
|
|
859
|
-
if (ref && moved.has(ref[key])) ref[key] = moved.get(ref[key]);
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
857
|
return { structural: true };
|
|
864
858
|
});
|
|
865
859
|
},
|
|
866
860
|
|
|
867
|
-
setPlanGrid(
|
|
861
|
+
setPlanGrid(viewId, grid) {
|
|
868
862
|
return session.transact('set model grid', (doc) => {
|
|
869
863
|
if (grid == null) doc.grid = null;
|
|
870
864
|
else {
|
|
871
|
-
const plan = { ...
|
|
865
|
+
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid || grid, grid: doc.grid || grid };
|
|
872
866
|
const next = clone(grid);
|
|
873
867
|
if (Array.isArray(next.origin)) {
|
|
874
868
|
const p = sheetPxToWorld(next.origin, plan, { unknown: true });
|
|
@@ -902,10 +896,10 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
902
896
|
});
|
|
903
897
|
},
|
|
904
898
|
|
|
905
|
-
addGridLine(
|
|
899
|
+
addGridLine(viewId, line) {
|
|
906
900
|
return session.transact('add grid line', (doc) => {
|
|
907
901
|
if (!doc.grid) throw new V2CommandError('grid-unavailable', 'the model has no grid');
|
|
908
|
-
const plan = { ...
|
|
902
|
+
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid };
|
|
909
903
|
const next = clone(line);
|
|
910
904
|
for (const key of ['a', 'b']) {
|
|
911
905
|
const p = sheetPxToWorld(next[key], plan, { unknown: true });
|
|
@@ -916,11 +910,11 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
916
910
|
});
|
|
917
911
|
},
|
|
918
912
|
|
|
919
|
-
setGridLineEnds(
|
|
913
|
+
setGridLineEnds(viewId, id, a, b) {
|
|
920
914
|
return session.transact('move grid line', (doc) => {
|
|
921
915
|
const line = (doc.grid?.lines || []).find((row) => String(row.id) === String(id));
|
|
922
916
|
if (!line) throw new V2CommandError('grid-line-unresolved', `grid line "${id}" does not exist`);
|
|
923
|
-
const plan = { ...
|
|
917
|
+
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid };
|
|
924
918
|
const aw = sheetPxToWorld(a, plan, { unknown: true });
|
|
925
919
|
const bw = sheetPxToWorld(b, plan, { unknown: true });
|
|
926
920
|
line.a = [aw.x, aw.y]; line.b = [bw.x, bw.y];
|
|
@@ -928,9 +922,9 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
928
922
|
});
|
|
929
923
|
},
|
|
930
924
|
|
|
931
|
-
presentOnSheet(
|
|
932
|
-
return session.transact(on ? 'show members on
|
|
933
|
-
const plan =
|
|
925
|
+
presentOnSheet(viewId, ids, on) {
|
|
926
|
+
return session.transact(on ? 'show members on view' : 'hide members on view', (doc) => {
|
|
927
|
+
const plan = planByViewId(doc, viewId);
|
|
934
928
|
const selected = new Set(ids);
|
|
935
929
|
if (on) plan.memberRefs = [...new Set([...(plan.memberRefs || []), ...selected])];
|
|
936
930
|
else {
|
|
@@ -942,9 +936,9 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
942
936
|
});
|
|
943
937
|
},
|
|
944
938
|
|
|
945
|
-
copyMembers(
|
|
939
|
+
copyMembers(viewId, ids, offsetPx = [0, 0, 0]) {
|
|
946
940
|
return session.transact('copy members', (doc) => {
|
|
947
|
-
const plan = { ...
|
|
941
|
+
const plan = { ...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid };
|
|
948
942
|
const made = [];
|
|
949
943
|
for (const id of ids) {
|
|
950
944
|
const source = memberById(doc, id);
|
|
@@ -960,24 +954,26 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
960
954
|
copy.to.z = { known: known(copy.to.z, `${source.id}.to`) + dz };
|
|
961
955
|
}
|
|
962
956
|
doc.members.push(copy);
|
|
963
|
-
|
|
957
|
+
planByViewId(doc, viewId).memberRefs = [...new Set([...(planByViewId(doc, viewId).memberRefs || []), copy.id])];
|
|
964
958
|
made.push(copy.id);
|
|
965
959
|
}
|
|
966
960
|
return { changedIds: made, structural: true, value: made };
|
|
967
961
|
});
|
|
968
962
|
},
|
|
969
963
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
964
|
+
// Both ends are VIEW ids (#938) — `entries[].sourceViewId` names the row the member is being taken
|
|
965
|
+
// from, which on a page with several views is not answerable from the page name.
|
|
966
|
+
moveOrCopyToView(targetViewId, entries, copy = false) {
|
|
967
|
+
return session.transact(copy ? 'copy members to view' : 'move members to view', (doc) => {
|
|
968
|
+
const target = planByViewId(doc, targetViewId);
|
|
973
969
|
if (!Number.isFinite(target.elevation_in)) {
|
|
974
|
-
throw new V2CommandError('target-elevation-unknown', `
|
|
970
|
+
throw new V2CommandError('target-elevation-unknown', `drawing view "${targetViewId}" has no known plan elevation`);
|
|
975
971
|
}
|
|
976
972
|
const made = [];
|
|
977
973
|
for (const entry of entries || []) {
|
|
978
|
-
const sourcePlan =
|
|
974
|
+
const sourcePlan = planByViewId(doc, entry.sourceViewId);
|
|
979
975
|
if (!Number.isFinite(sourcePlan.elevation_in)) {
|
|
980
|
-
throw new V2CommandError('source-elevation-unknown', `
|
|
976
|
+
throw new V2CommandError('source-elevation-unknown', `drawing view "${entry.sourceViewId}" has no known plan elevation`);
|
|
981
977
|
}
|
|
982
978
|
const source = memberById(doc, entry.id);
|
|
983
979
|
const member = copy ? detachCopiedEngineeringReferences(clone(source)) : source;
|
|
@@ -999,12 +995,12 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
999
995
|
});
|
|
1000
996
|
},
|
|
1001
997
|
|
|
1002
|
-
splitMember(
|
|
998
|
+
splitMember(viewId, memberId, splitPx) {
|
|
1003
999
|
return session.transact('split member', (doc) => {
|
|
1004
1000
|
const original = memberById(doc, memberId);
|
|
1005
1001
|
assertNoWholeMemberRefs(doc, new Set([memberId]));
|
|
1006
1002
|
const split = sheetPxToWorld(splitPx, {
|
|
1007
|
-
...
|
|
1003
|
+
...planByViewId(doc, viewId), modelGrid: doc.grid, grid: doc.grid,
|
|
1008
1004
|
}, clone(original.from.z));
|
|
1009
1005
|
if (!pointOnSegment(split, original.from, original.to)
|
|
1010
1006
|
|| Math.hypot(split.x - original.from.x, split.y - original.from.y) <= 1e-6
|
|
@@ -1026,16 +1022,16 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
1026
1022
|
});
|
|
1027
1023
|
},
|
|
1028
1024
|
|
|
1029
|
-
mergeMembers(
|
|
1025
|
+
mergeMembers(viewId, memberIds, mergedPx) {
|
|
1030
1026
|
return session.transact('merge members', (doc) => {
|
|
1031
|
-
const id = mergeMemberGroup(doc,
|
|
1027
|
+
const id = mergeMemberGroup(doc, viewId, memberIds, mergedPx, mintId, resolveSection);
|
|
1032
1028
|
return { changedIds: [id], structural: true, value: id };
|
|
1033
1029
|
});
|
|
1034
1030
|
},
|
|
1035
1031
|
|
|
1036
|
-
mergeMemberGroups(
|
|
1032
|
+
mergeMemberGroups(viewId, groups) {
|
|
1037
1033
|
return session.transact('merge member groups', (doc) => {
|
|
1038
|
-
const made = groups.map((group) => mergeMemberGroup(doc,
|
|
1034
|
+
const made = groups.map((group) => mergeMemberGroup(doc, viewId, group.memberIds, group.wp, mintId, resolveSection));
|
|
1039
1035
|
return { changedIds: made, structural: true, value: made };
|
|
1040
1036
|
});
|
|
1041
1037
|
},
|
|
@@ -1048,12 +1044,12 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
1048
1044
|
},
|
|
1049
1045
|
|
|
1050
1046
|
/**
|
|
1051
|
-
* @param {string}
|
|
1047
|
+
* @param {string} viewId
|
|
1052
1048
|
* @param {{memberIds?: string[], dimIds?: string[], jointIds?: string[], gridLineIds?: string[]}} selection
|
|
1053
1049
|
*/
|
|
1054
|
-
deleteSelection(
|
|
1050
|
+
deleteSelection(viewId, { memberIds = [], dimIds = [], jointIds = [], gridLineIds = [] } = {}) {
|
|
1055
1051
|
return session.transact('delete selection', (doc) => {
|
|
1056
|
-
const plan =
|
|
1052
|
+
const plan = planByViewId(doc, viewId);
|
|
1057
1053
|
const dims = new Set(dimIds), joints = new Set(jointIds), lines = new Set(gridLineIds);
|
|
1058
1054
|
if (dims.size) plan.dims = (plan.dims || []).filter((dim) => !dims.has(dim.id));
|
|
1059
1055
|
if (joints.size) doc.joints = (doc.joints || []).filter((joint) => !joints.has(joint.id));
|
|
@@ -1098,25 +1094,25 @@ export function dispatchV2ProjectionCommand(target, operation, args = []) {
|
|
|
1098
1094
|
case 'reverseEnds': s.reverseEndMetadata(link.memberId); return true;
|
|
1099
1095
|
case 'elevateBy': s.offsetElevation(link.memberId, args[0]); return true;
|
|
1100
1096
|
case 'retargetTos': s.retargetElevation(link.memberId, args[0], args[1]); return true;
|
|
1101
|
-
case 'setEndpoint': s.setEndpointPx(link.
|
|
1102
|
-
case 'setEndpointsInPlace': s.setEndpointsPx(link.
|
|
1103
|
-
case 'replaceEndpoints': s.setEndpointsPx(link.
|
|
1097
|
+
case 'setEndpoint': s.setEndpointPx(link.viewId, link.memberId, args[0], args[1]); return true;
|
|
1098
|
+
case 'setEndpointsInPlace': s.setEndpointsPx(link.viewId, link.memberId, args[0], args[1]); return true;
|
|
1099
|
+
case 'replaceEndpoints': s.setEndpointsPx(link.viewId, link.memberId, args[0][0], args[0][1]); return true;
|
|
1104
1100
|
case 'moveWorkPoints': s.moveWorkPoints(link.memberId, args[0]); return true; // world mm, no sheet — the 3D gizmo's reference-line handles (slice 3b.1)
|
|
1105
1101
|
case 'translate':
|
|
1106
|
-
s.translatePx(link.
|
|
1102
|
+
s.translatePx(link.viewId, args[0].map((m) => projectionLink(m)?.memberId).filter(Boolean), args[1]);
|
|
1107
1103
|
return true;
|
|
1108
|
-
case 'addMember': s.addMemberPx(link.
|
|
1104
|
+
case 'addMember': s.addMemberPx(link.viewId, args[0]); return true;
|
|
1109
1105
|
case 'removeMembers': s.deleteMembers(args[0]); return true;
|
|
1110
1106
|
case 'setMemberType': s.patchMember(link.memberId, { memberType: args[0] }); return true;
|
|
1111
1107
|
case 'patchMember': s.patchMember(link.memberId, args[0]); return true;
|
|
1112
1108
|
case 'patchEnd': s.patchEnd(link.memberId, link.kind === 'column' ? 1 : link.end, args[0]); return true;
|
|
1113
1109
|
case 'setMemberBrace': s.patchMember(link.memberId, { brace: args[0] == null ? undefined : args[0] }); return true;
|
|
1114
1110
|
case 'patchMemberBrace': s.patchMember(link.memberId, { brace: { ...(target || {}), ...(args[0] || {}) } }); return true;
|
|
1115
|
-
case 'patchGrid': s.patchGrid(link.
|
|
1111
|
+
case 'patchGrid': s.patchGrid(link.viewId, args[0]); return true;
|
|
1116
1112
|
case 'setGridLabels': s.setGridLabels(args[0], args[1]); return true;
|
|
1117
|
-
case 'setPlanGrid': s.setPlanGrid(link.
|
|
1113
|
+
case 'setPlanGrid': s.setPlanGrid(link.viewId, args[0]); return true;
|
|
1118
1114
|
case 'ensurePlanGrid':
|
|
1119
|
-
if (!target.grid) s.setPlanGrid(link.
|
|
1115
|
+
if (!target.grid) s.setPlanGrid(link.viewId, args[0]());
|
|
1120
1116
|
return true;
|
|
1121
1117
|
case 'removeGridLines': s.removeGridLines(args[0]); return true;
|
|
1122
1118
|
case 'clearGridLines': s.removeGridLines(new Set((target.lines || []).map((line) => String(line.id)))); return true;
|
|
@@ -1125,16 +1121,16 @@ export function dispatchV2ProjectionCommand(target, operation, args = []) {
|
|
|
1125
1121
|
if (!line) return true;
|
|
1126
1122
|
s.setGridLineLabel(String(line.id), args[1]); return true;
|
|
1127
1123
|
}
|
|
1128
|
-
case 'setGridLineEnds': s.setGridLineEnds(link.
|
|
1129
|
-
case 'addGridLine': s.addGridLine(link.
|
|
1124
|
+
case 'setGridLineEnds': s.setGridLineEnds(link.viewId, link.gridLineId, args[0], args[1]); return true;
|
|
1125
|
+
case 'addGridLine': s.addGridLine(link.viewId, args[0]); return true;
|
|
1130
1126
|
case 'setPlanDefaultTos':
|
|
1131
1127
|
throw new V2CommandError('default-tos-retired', 'steel.model/v2 stores explicit endpoint elevations and has no sheet default T.O.S link');
|
|
1132
1128
|
case 'setPlanMembers':
|
|
1133
1129
|
throw new V2CommandError('structural-operation-explicit', 'v2 merge/split/delete commands must declare identity and reference reconciliation');
|
|
1134
|
-
case 'setPlanDims': s.patchPlan(link.
|
|
1135
|
-
case 'addPlanDims': s.addPlanDims(link.
|
|
1136
|
-
case 'setPlanFrame': s.patchPlan(link.
|
|
1137
|
-
case 'detachDimRefs': s.detachDimRefs(link.
|
|
1130
|
+
case 'setPlanDims': s.patchPlan(link.viewId, { dims: args[0] }); return true;
|
|
1131
|
+
case 'addPlanDims': s.addPlanDims(link.viewId, args[0]); return true;
|
|
1132
|
+
case 'setPlanFrame': s.patchPlan(link.viewId, { frame: args[0] }); return true;
|
|
1133
|
+
case 'detachDimRefs': s.detachDimRefs(link.viewId, args[0]); return true;
|
|
1138
1134
|
default:
|
|
1139
1135
|
throw new V2CommandError('projection-command-unimplemented', `no v2 projection arm exists for ${operation}`);
|
|
1140
1136
|
}
|