Repository navigation
扩展 SolidWorks 原生工具至 192 个并记录全覆盖缺口 - #4
Merged
Merged
Conversation
Nine tool functions imported helpers with `from sw_core import ...` instead of the package-relative `from .sw_core import ...`. Once the package is installed, or imported as `solidworks_mcp`, there is no top-level `sw_core` module, so each of these tools raised ModuleNotFoundError on its first call: create_axis, draw_spline, sketch_mirror, set_appearance, list_mates, set_drawing_view, insert_section_view, insert_detail_view, and the selected-only path of insert_center_marks. Verified against a live SOLIDWORKS 2016 SP3 session (German UI): all nine tools now run and their results were checked numerically. The offline suite and the server import stay green. Co-Authored-By: Claude Fable 5.1 <[email protected]>
set_material verified its work by calling GetMaterialPropertyName2 with the database as a plain string. SOLIDWORKS 2016 returns an empty name for that form even though the material was applied -- the mass changes -- so the tool reported failure on every call there. The database argument is [in, out], so pass it as a typed by-reference VARIANT first, accept a tuple return, and fall back to MaterialIdName, which reports "database|name" and has been stable since 2008. Verified on 2016: 'AISI 1020' reads back as such and moves a 36 cm^3 block from 36 g to 284 g; an unknown name still reports the material actually on the part. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…west
Each SOLIDWORKS release adds numbered method variants whose argument list
extends the previous one, and keeps the old names. The server always called
the newest, so on a build without it -- SOLIDWORKS 2016 has no FeatureCut4 --
cut_extrude, sweep, linear_pattern, circular_pattern and insert_detail_view
raised AttributeError on every call.
call_versioned() in sw_core tries the candidates in order and treats
AttributeError as "not on this build", remembering absent names in
_UNFLAGGABLE_NAMES so the cross-process lookup is not repeated. The older
names join the flag lists so they are flagged as methods like everything
else. Read off the 2016 type library with tools/tlb_probe.py, every older
variant takes a strict prefix of the arguments already passed:
FeatureCut3 26 of 27
InsertProtrusionSwept3 17 of 20
InsertCutSwept4 19 of 22
FeatureLinearPattern4 20 of 22
FeatureCircularPattern4 7 of 14
CreateDetailViewAt3 9 of 12
On newer releases the first candidate always resolves, so behaviour there is
unchanged. Verified numerically against a live SOLIDWORKS 2016 SP3 session:
the through-all cut removes pi*8^2*20 mm^3 exactly, the linear and circular
patterns remove exactly one and five further holes, the swept rod and its
swept cut match pi*r^2*L, and the detail view appears at the requested scale.
The offline suite gains tests for the helper and for the flag lists.
Refs #1
Co-Authored-By: Claude Fable 5.1 <[email protected]>
- 新增 8 个 MotionManager 工具:运动特征清单、引力、线性/旋转马达、原生求解、 逐时间结果采样、动画序列、播放控制、帧序列/视频导出,合计 188 个工具 - 零件文档上添加引力或马达改为带 document_type 的结构化失败,不再触发 -2147417851 原生 COM 服务器错误 - insert_component 插入后恢复装配体为活动文档并读回 active_document,避免 静默打开零件后后续装配体工具全部失败 - 安装协议改为装配体加插入零件的真实 Motion 流程:215 项离线测试、188 个唯一 工具的 stdio 发现、引力/结果/求解/零件拒绝对照/帧导出与播放全部通过
- 新增 4 个 Motion 载荷工具:线性力/力矩、线性/扭转/线性运动/扭转运动弹簧、 线性/扭转阻尼、3D 接触,合计 192 个工具 - CreateFeature 返回的 dispatch 在本机报告的是上一个特征,创建改为前后对比 GetMotionFeatures 识别新条目;引力与马达同步改用同一路径 - 两个端点必须放在同一选择集的两个标记里(mark 1 与追加的 mark 2), 否则第二选择会替换第一选择 - 3D 接触的 ContactComponents 固定使用 SAFEARRAY(VT_ARRAY|VT_DISPATCH), 元组赋值被原生静默忽略 - 新增 7 项离线测试与实机载荷回归脚本;覆盖率映射、COVERAGE、README 与安装 协议同步到 192 工具,安装验收为 222 项离线测试 + 192 个唯一工具 stdio 发现
Slacker-LLC
marked this pull request as ready for review
October 13, 2026 18:54
RIPBillyMays
pushed a commit
to RIPBillyMays/solidworks-mcp
that referenced
this pull request
Oct 13, 2026
…, active document in results - Sketch draw tools create entities with AddToDB on (no inference snapping), read geometry back and return ok:false with requested/actual on mismatch. New draw_polyline tool. draw_polygon honours inscribed=false on 2017. - Tool results carry active_document; new activate_document tool. - Live probes of field findings (Slacker-LLC#1 reproduced; Slacker-LLC#3/Slacker-LLC#4/Slacker-LLC#6/Slacker-LLC#8 not), offline and live verification reports, plan update (Slacker-LLC#4/Slacker-LLC#6/Slacker-LLC#8 parked in Phase 7). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现有 MCP 的工具数量不足,配置、属性、方程、多实体编辑、钣金、焊件、直接编辑和官方 Motion 等操作存在缺口。本改动将默认工具从 92 个扩展到 192 个,并补充原生选择标记、单位转换、重建错误与实际结果读回。
覆盖范围包括 SolidWorks 本体及官方自带、随附模块,排除嘉立创等第三方插件。
COVERAGE.md和类型库清点/缺口报告保留尚未实现或未验证的功能;192 个工具不代表全覆盖。检查点合并,后续批次在独立分支继续补齐。包含 PR #2 的已有旧版 API、包内导入和材质读取兼容改动,在此基础上修复跨 COM 对象的可用成员缓存误判。新增数值坐标系 API 要求 SolidWorks 2022+;现代扫描曲面定义要求 SolidWorks 2018+;新增工具的实机验证环境为 SolidWorks 2026 SP3.2,未宣称旧版本已验证。
本批:Motion 载荷(力/力矩、弹簧、阻尼、3D 接触)
新增 4 个原生载荷工具:
add_motion_force、add_motion_spring、add_motion_damper、add_motion_contact。载荷按类型库swFeatureNameID_e值 75/76(线性力、力矩)、79–82(线性、扭转、线性运动、扭转运动弹簧)、83/84(线性、扭转阻尼)、85(3D 接触)经CreateDefinition+CreateFeature创建,随后读回原生定义里的实际数值,不把返回码当作成功。本批查出并修复一个影响全部运动特征创建的缺陷:
CreateFeature返回的 dispatch 在本机报告的是上一个特征的名称与类型,原来的“返回对象出现在特征清单中”判据可能把旧特征当作新特征。现在创建前后对比GetMotionFeatures()取新增条目,用该条目的原生类型与参数读回判定成功;add_motion_gravity与add_motion_motor同步改用同一路径。两个端点必须放在同一选择集的两个标记里(mark 1 与追加的 mark 2)。第二个选择不 append 会替换第一个选择,弹簧创建随即以
SetEndPoints类型不匹配失败。验证:
ForceType0、常量函数 0)、力矩 5 N·m 反向(ForceType1)、线性弹簧(常数 1、自由长度 0.05)、扭转弹簧(常数 2)、线性运动弹簧(3 圈读回 3)、线性阻尼 0.5、扭转阻尼 0.75、3D 接触(刚度 100000、指数 2、最大阻尼 1000、穿透 0.0001、摩擦 full 读回 1、恢复系数 0.3)。特征类型为AEMLinearForce、AEMTorque、AEMLinearSpring、AEMTorsionalSpring、AEMLinearDamper、AEMTorsionalDamper、AEM3DContact。ContactComponents只接受 SAFEARRAY(VT_ARRAY|VT_DISPATCH);元组赋值被原生静默忽略,工具固定使用前者并读回摩擦、恢复系数与刚度。.development。FreeAngle属性在本机类型库存在但读写均抛AttributeError;力函数只验证常量类型,step/harmonic/function/spline 的函数值未专项验证。.development日志中;其中复杂转换零件里的轴向尺寸原生拒绝未被本批修复,仍为缺口。上一批:Motion 求解、结果与动画
在原有 Motion 算例生命周期工具之上新增 8 个:算例特征清单、引力、线性/旋转马达、原生求解、逐时间结果采样、动画序列、播放控制、帧序列/视频导出。所有写操作读回原生定义或结果对象,不把返回码当作成功。
该批同时修正两个已有工具的原生行为:
CreateFeature抛原生 COM 异常(-2147417851 服务器出现意外情况)。现在两类运动元素在接触 MotionManager 前检查文档类型,零件文档返回带document_type="part"的结构化失败,不再产生原生异常。insert_component为加载引用文件而静默OpenDoc6,会把活动文档切成被插入的零件,后续装配体工具随即以“requires an active assembly document”失败。现在插入后恢复装配体为活动文档并读回active_document,未恢复时报告插入已完成但活动文档仍在别处。该批验证:215 项离线测试通过(新增 2 项零件拒绝、3 项插入后活动文档恢复);实机引力强度 9.81/轴 y/反向读回,特征类型 AEMGravity;线性马达 25 RPM、旋转马达 30 RPM 反向,MotorType 0/1 读回;结果采样 3 个时间点各返回 3 分量;rotate_model 时间轴 0→2.0 s;PNG 帧序列真实写出 16 个文件共 3,369,810 字节;loop 播放与停止读回。按事实记为失败而非成功:重力+马达装配体求解
Calculate=True、IsOutOfDate=False,但 0/0.5/1.0 s 的质心、速度与加速度均无变化;Explode/Collapse 原生返回 True 但时间轴未变;AVI 编码原生返回 False 且无文件;Motion Analysis 类型设置被静默忽略,本机无 ADAMS 动力学插件。仍有缺口:Motion 的曲线图/CSV 结果、求解器/许可可用时的真实动力学验证、AVI/JPG 编码、PhotoWorks 渲染器、帧率读写、图像尺寸参数与事件回调;求解后 SOLIDWORKS 拒绝跨文档激活(
ActivateDoc3返回成功但活动文档不变)。Simulation、CAM、Routing 等其他官方模块尚未覆盖。基准面参考点投影、删除面填充/相切填充模式、填充曲率控制、法向直纹反向、中面非零位置、曲面相互修剪非缝合选项、边界曲面相切/曲率控制、包覆反向几何与方向引用保存等原生拒绝或未生效项继续保留在覆盖目标内。嘉立创等真正第三方厂商插件不在范围内。