maxwell 作为com对象分析
n5321 | 2025年10月30日 22:20
matlab 有invoke 函数来探测COM!
在python 下面用的dir
dir(self.maxwell_app) ['Design', 'Desktop', 'Editor', 'Module', 'Project', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'analyze_design', 'connect_maxwell', 'export_reports', 'iMaxwell', 'open_project_and_design', 'release_maxwell', 'set_properties']
具体来看:
MaxwellAutomation 类结构概览
🧩 一、核心对象属性(Attributes)
| 属性名 | 类型/用途 | 说明 |
|---|---|---|
Desktop | AEDT 桌面对象(oDesktop) | 控制 Maxwell AEDT 会话、项目打开、退出等操作。 |
Project | AEDT 工程对象(oProject) | 当前打开的 Maxwell 工程。 |
Design | AEDT 设计对象(oDesign) | 当前工程下的具体设计,如“RMxprtDesign”或“Maxwell3DDesign”。 |
Editor | AEDT 编辑器对象(oEditor) | 用于修改几何、材料、属性、参数。通常是 "3D Modeler" 编辑器。 |
Module | AEDT 模块对象(oModule) | 可调用报告、求解、场后处理等功能模块,如 "ReportSetup"、"FieldsReporter" 等。 |
iMaxwell | COM 接口对象 | 由 win32com.client.Dispatch("Ansoft.ElectronicsDesktop") 获取,用于连接 AEDT。 |
⚙️ 二、主要方法(Methods)
| 方法名 | 主要功能 | 典型调用示例 |
|---|---|---|
__init__() | 初始化 MaxwellAutomation 实例 | app = MaxwellAutomation() |
connect_maxwell() | 建立与 Maxwell AEDT 的 COM 连接 | app.connect_maxwell() |
open_project_and_design(config) | 打开指定工程与设计 | app.open_project_and_design(config) |
set_properties(property_changes) | 批量修改参数属性 | app.set_properties(property_changes) |
analyze_design(setup_name) | 启动指定 Setup 的仿真 | app.analyze_design("Setup1") |
export_reports(config) | 导出仿真结果报告或数据文件 | app.export_reports(config) |
release_maxwell() | 关闭并释放 Maxwell 会话 | app.release_maxwell() |
🧱 三、内置 Python 魔法方法(不需手动调用)
这些是 Python 自动提供的类方法,用于对象描述、比较、属性访问等,一般不手动使用:
| 方法 | 功能 |
|---|---|
__init__ | 构造函数 |
__str__ / __repr__ | 控制打印输出格式 |
__eq__, __lt__, __gt__ | 对象比较 |
__getattribute__, __setattr__ | 控制属性访问 |
__dict__, __doc__ | 存放实例属性与文档说明 |
__sizeof__, __reduce__, __module__ | 内部运行支持 |