Skip to content

bug(tools): save_body_as_part opens a linked assembly and leaves it open #101

Open

Description

@andrewbartels1

Symptom

After a successful save_body_as_part call, an extra Assem<N> document is
open in SolidWorks (unsaved, no path). Reproduced live during the PR #99
tutorial run — list_open_documents afterwards showed the source part plus an
Assem14 that the tool never mentions.

Cause

IFeatureManager::CreateSaveBodyFeature in
src/solidworks_mcp/adapters/solidworks/io.py save_body_as_part is called
as:

manager.CreateSaveBodyFeature(
    _variant_array(pythoncom.VT_DISPATCH, [match]),
    _variant_array(pythoncom.VT_BSTR, [target]),
    "",      # AssemblyName
    False,
    True,
)

SolidWorks' Save Bodies feature has a "Create assembly" option that is on by
default; one of the trailing args (or the empty AssemblyName being treated as
"auto") is triggering assembly creation. The standalone .sldprt is still
written correctly — this is just an unwanted side document.

Impact

Low — the file write (the tool's actual contract) works and is verified. But
the stray assembly:

  • pollutes list_open_documents
  • can confuse close_model (which acts on the active doc) in a cleanup loop
  • is surprising: the tool's docstring says nothing about an assembly

Fix

Confirm the exact CreateSaveBodyFeature signature against sldworks.tlb on
the target install, pass the arg combination that suppresses assembly
creation, and if an assembly is unavoidable, either close it in the tool or
document it and return its name in the response.

Context

PR #99, tutorial docs/getting-started/tutorials/wave3-reference-geometry-and-drawings.md
("Save Bodies opens a linked assembly" note).

Activity

  1. added
    bugSomething isn't working
    triageNeeds initial review and routing
    on Sep 7, 2026
  2. andrewbartels1 commented on Oct 13, 2026

    @andrewbartels1
    OwnerAuthor

    Still reproduces on main (600624f), SW R2026x. After save_body_as_part on a single-body box, list_open_documents shows the source part plus two extra docs: the extracted body.SLDPRT (left open) and an unsaved Assem4 (active). The fix should close both, or not open them, and leave the source part active.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNeeds initial review and routing

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions