Skip to content

fix: P134 set_material verifies (zh/en names), run_macro binds swApp/Part and reports where it stopped - #5

Merged
raylanlin merged 1 commit into
masterfrom
claude/gracious-davinci-j7qso7
Oct 2, 2026
Merged

raylanlin merged 1 commit into
masterfrom
claude/gracious-davinci-j7qso7

Conversation

@raylanlin

@raylanlin raylanlin commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

What Changed

v0.2.133 (P134). This fixes three problems seen in a real session: the part was built correctly, but its material was never applied, and the agent then spent about ten calls on macros that silently did nothing.

  • set_material
    • Before: it reported success while nothing was applied. SetMaterialPropertyName2 returns nothing and silently ignores unknown names; a Chinese install has 「合金钢」, not "Alloy Steel".
    • Now: it tries each candidate (the given name, then its zh/en alias, in both database spellings) and verifies each by reading the density back.
    • If nothing takes: that is an error. An unchanged density on a part that already had a material returns verified:false instead of claiming success.
  • run_macro: nothing was bound
    • The tool promised that swApp and Part were bound, but nothing assigned them.
    • The entry Sub now binds swApp / Part / swModel when the macro uses them.
  • run_macro: runtime errors reported as success
    • A runtime error in the entry Sub still came back as "脚本执行完成".
    • Fix: the entry Sub is now instrumented:
      • Before each statement it records the line number and text. It skips continuation lines and the line just after Select Case.
      • A completion flag is set at the end of the Sub and on every Exit Sub.
    • Result: a macro that did not reach its end fails and names the line it stopped on.
  • Connection note: attached to the first result only, and it now distinguishes three cases: SolidWorks not running, a background instance shown, a second instance started.

Related Issue

N/A

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 📝 Documentation
  • ♻️ Refactor
  • 🧪 Tests
  • 🔧 Build / CI

Testing

  • npm test passes (201 tests). New vba-macro-writer tests cover binding, the completion flag, line reporting, and no marker where VBScript forbids a statement.
  • npm run lint passes. typecheck, ruff, pytest (67 tests) and compileall also pass. New set_material tests cover the zh fallback, an error when nothing takes, and the ambiguous case.
  • Manual test on Windows + SolidWorks (the generated VBScript cannot be executed on the Linux CI):
    • set steel and read the mass
    • a run_macro that reads Part.GetTitle
    • a deliberately broken macro, which should fail and name its line

Checklist

  • Code follows project conventions
  • Self-reviewed
  • Docs updated (if needed)
  • CHANGELOG.md updated (if needed)

…Part and reports where it stopped

set_material: SetMaterialPropertyName2 returns nothing and silently ignores an
unknown name (a Chinese install has 合金钢, not "Alloy Steel"), so the tool reported
success while the tree said 材质 <未指定> and masses came out at water density. Each
candidate (given name, then its zh/en alias, both database spellings) is now applied
and verified by reading the density back; nothing taking is an error.

run_macro: the description promised swApp and Part were bound, but nothing assigned
them, and a runtime error inside the entry Sub reached the runner with Err clear, so
broken macros "completed". The entry Sub now binds swApp/Part/swModel when used,
records line number + text before each statement (skipping continuation lines and
the first line after Select Case) and sets a completion flag at its end and on every
Exit Sub; a macro that did not reach the end fails with the line it stopped on.

Connection note: first result only, and distinguishes not-running / background
instance shown / second instance started.

201 JS + 67 Python tests pass; typecheck, lint, ruff, compileall OK.
@raylanlin
raylanlin merged commit f50aa3f into master Oct 2, 2026
1 check passed
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