feat(web): object picker in workbench shell, verify sketch panel on stage
workbench.html routes Sketcher desktop commands to the standalone sketcher probe, which had no document, so Sketcher_EditSketch always failed with "The selected live document does not exist in this runtime". The shell also only exposed an object selection table for BIM, so no command could receive a selected sketch. - workbench shell: add a generic document object list (details .workbench-object-picker) that writes both the shell selection and the command payload selection for every module - ch03: document the working session path (NewSketch creates workbench_document/Sketch, then EditSketch on that selection) with two stage screenshots, plus the measured layout (panel left 284 vs stage left 260, zero horizontal overflow) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -4346,6 +4346,43 @@ export function WorkbenchShell({
|
||||
</button>
|
||||
<p role="status">当前文档:{documentSelection.documentId || "未绑定"}</p>
|
||||
</details>
|
||||
{(() => {
|
||||
// Desktop FreeCAD acts on the tree selection. The workbench shell only had a
|
||||
// selection table for BIM and a viewport selection for Web/Std_Open, so
|
||||
// commands like Sketcher_EditSketch could never receive a selected object.
|
||||
const tree = nativeDocuments[documentSelection.documentId];
|
||||
if (!tree?.objects.length) return null;
|
||||
const select = (name: string, checked: boolean) => {
|
||||
setDocumentSelection(current => ({
|
||||
documentId: current.documentId,
|
||||
selection: checked
|
||||
? [...current.selection.filter(entry => entry.object !== name), { documentId: current.documentId, object: name }]
|
||||
: current.selection.filter(entry => entry.object !== name),
|
||||
}));
|
||||
setPayloadText(current => {
|
||||
try {
|
||||
const args = JSON.parse(current);
|
||||
if (!args || typeof args !== "object" || Array.isArray(args)) return current;
|
||||
const kept = Array.isArray(args.selection)
|
||||
? args.selection.filter((entry: { object?: string }) => entry?.object !== name) : [];
|
||||
const selection = checked ? [...kept, { documentId: documentSelection.documentId, object: name }] : kept;
|
||||
return JSON.stringify({ ...args, documentId: documentSelection.documentId, selection }, null, 2);
|
||||
} catch { return current; }
|
||||
});
|
||||
};
|
||||
return <details className="workbench-object-picker" open>
|
||||
<summary>文档对象 · 选择({documentSelection.documentId})</summary>
|
||||
<ul role="list">
|
||||
{tree.objects.map(object => <li key={object.name}>
|
||||
<label><input type="checkbox" disabled={busy}
|
||||
aria-label={`Select object ${object.label ?? object.name}`}
|
||||
checked={documentSelection.selection.some(entry => entry.object === object.name)}
|
||||
onChange={event => select(object.name, event.target.checked)} />
|
||||
{" "}{object.label ?? object.name} <small>{object.typeId}</small></label>
|
||||
</li>)}
|
||||
</ul>
|
||||
</details>;
|
||||
})()}
|
||||
{module === "TemplatePyMod" && <TemplatePyModCommandSurfaces busy={busy || pythonQtActive}
|
||||
hasDocument={Boolean(documentSelection.documentId)}
|
||||
available={name => moduleMatrixRecords.some(item => item.kind === "desktop-gui" && item.command === name)}
|
||||
|
||||
Reference in New Issue
Block a user