Skip to content

Equations and global variables drive a part's dimensions - #250

Open
andrewbartels1 wants to merge 1 commit into
mainfrom
feat/equations
Open

andrewbartels1 wants to merge 1 commit into
mainfrom
feat/equations

Conversation

@andrewbartels1

Copy link
Copy Markdown
Owner

Equations and global variables (queue item 29)

Equations and global variables are how a SolidWorks part becomes parametric: one value drives several dimensions, so changing it resizes the part consistently. The server had nothing for them. This adds three tools (143 in all):

Tool What it does
list_equations Every equation and global variable, in order, with name, expression, kind (global_variable, dimension, other) and its solved value
set_equation Adds an equation for name, or changes the one there is; solves and rebuilds; replies with the value and whether it was added or changed
delete_equation Removes one by name; a dimension it drove keeps its last value
  • Name and expression, not raw text. The agent gives name (Width, or a dimension such as D1@Sketch1) and expression (60mm, "Width" / 2); the server writes "Width" = 60mm, so the quoting is always right.
  • Configurations. all by default, as SolidWorks' Equations dialog does; this or a list of names, checked like set_dimension's.
  • Refusals change nothing. A dimension the model doesn't have is refused before anything is written (invalid_input). An expression SolidWorks can't use fails as the new equation_refused: an added equation is deleted again, and a changed one gets its old text back. Refusal is detected from Add3's -1, the manager's Status, and reading the stored text back.

Checks

  • Unit tests for the real adapter (fake equation manager), the mock, both wrappers and the tools: 4,383 pass at 100% coverage; ruff and mypy are clean; the docs build in strict mode.

  • Docs: a catalog page, the agent skill's workflow for driving dimensions from one value, the CHANGELOG, the tool counts.

  • Live: not run yet. tests/live/test_live_sw_equations.py has two cases:

    • Depth = 30mm drives a block's extrusion depth; Depth = 45mm makes it 45 mm deep (72,000 mm³); a bad expression is refused and the list is unchanged; deleting the depth equation keeps 45 mm. The evidence also shows what units Value reports.
    • Depth = 50mm in Long only: Long is 50 mm deep, Default stays 30 mm.
    powershell -ExecutionPolicy Bypass -File tests\scripts\live_demo.ps1 -Test tests/live/test_live_sw_equations.py

list_equations, set_equation and delete_equation (queue item 29). One
value ("Width" = 60mm) can drive several dimensions ("D1@Sketch1" =
"Width" / 2). set_equation adds or changes one, in every configuration
by default, solves and rebuilds, and gives the new value; an expression
SolidWorks can't use fails as equation_refused and changes nothing.
143 tools.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant