feat(solver): pack SolveContext into .kc archives on save (#289 phase 3d) #302
Reference in New Issue
Block a user
Delete Branch "feat/solver-context-packing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Expose
AssemblyObject::getSolveContext()to Python and hook into the.kcsave flow so thatsilo/solver/context.jsonis packed into every assembly archive on save. This lets server-side solver runners operate on pre-extracted constraint graphs without a full FreeCAD installation.Implements phase 3d of #289.
Changes
getSolveContext()that mirrors the setup insolve()(clear maps → get grounded → get joints → build context) but skips solver invocation, placement updates, and undo trackinggetSolveContext() -> dictSolveContextstruct to a Python dict matchingkcsolve.SolveContext.to_dict()format exactly (enum-to-string switch tables + Py::Dict/Py::List builders for all nested types)_solver_context_hookas a pre-reinject hook: on every.kcsave, if the document contains anAssembly::AssemblyObject, extracts the context and packs it assilo/solver/context.jsonsilo/solver/context.jsonto_KNOWN_ENTRIESso it appears in the document treeTesting
cmake --build build/release --target Assembly)assembly.getSolveContext()returns a dict with keysapi_version,parts,constraints,motions,simulation,bundle_fixedkcsolve.SolveContext.from_dict(ctx).kcfiles:silo/solver/context.jsonis not present