mcpField
A
acad-arx-wizard

acad-arx-wizard

github.com/autodesk-platform-services开发3153 次安装4 周前更新
代码仓库

关于 acad-arx-wizard

acad-arx-wizard 通过 PowerShell 脚本生成 ObjectARX C++ 项目和类,面向使用 Visual Studio 2026 的 AutoCAD 2027 开发者,也可替代故障的经典向导。

主要功能

  1. 01生成 ARX、DBX 或 CRX 项目
  2. 02创建常见 ObjectARX 类
  3. 03收集脚本所需参数
  4. 04提供构建配置参考
  5. 05排查脚手架与构建问题

适用场景

  1. 01创建新的 ObjectARX 项目
  2. 02添加 Jig 或 Reactor 类
  3. 03生成 MFC、.NET 或 COM 包装类
  4. 04诊断 SDK 或链接器配置问题

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/autodesk-platform-services/skills --skill acad-arx-wizard

安装后在 Claude Code 中输入/acad-arx-wizard确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

README.md
docs/
arx-dev-guide.md
learnings.md
props/
Autodesk.arx-2027-net.props
Autodesk.arx-2027.props
crx.props
scripts/
Invoke-TemplateExpansion.ps1
New-ArxApp.ps1
New-ArxComWrapper.ps1
New-ArxCustomObject.ps1
New-ArxDynProp.ps1
New-ArxJig.ps1
New-ArxMFCSupport.ps1
New-ArxNETWrapper.ps1
New-ArxReactors.ps1
templates/arx-app/
acrxEntryPoint.cpp
AssemblyInfo.cpp
Autodesk.arx-2027-net.props
Autodesk.arx-2027.props
crx.props
DocData.cpp
DocData.h
ReadMe.txt
Resource.h
root.cpp
root.idl
root.rc
root.rgs
StdAfx.cpp
StdAfx.h

详细介绍

ObjectARX Wizard Skill — AutoCAD 2027 / VS 2026

使用 AI 对话 + PowerShell 生成器搭建 ObjectARX C++ 项目和类。

Skill 位置

脚本与此 SKILL.md 位于同一文件夹中:

<skill-root>/
├── SKILL.md
├── docs/
│   ├── arx-dev-guide.md              ← ObjectARX 2027 build configuration reference
│   └── learnings.md                  ← live wiki: gotchas, workarounds, verified API behaviors
├── scripts/
│   ├── Invoke-TemplateExpansion.ps1   ← shared token engine (do not call directly)
│   ├── New-ArxApp.ps1                 ← full ARX/DBX/CRX project
│   ├── New-ArxCustomObject.ps1        ← custom ObjectDBX entity class
│   ├── New-ArxReactors.ps1            ← transient reactor class
│   ├── New-ArxJig.ps1                 ← AcEdJig subclass
│   ├── New-ArxMFCSupport.ps1          ← MFC dialog / palette / control
│   ├── New-ArxNETWrapper.ps1          ← managed .NET wrapper
│   ├── New-ArxComWrapper.ps1          ← ATL COM wrapper object
│   └── New-ArxDynProp.ps1             ← ATL dynamic property class
├── templates/                         ← source template files (do not edit)
└── props/                             ← Autodesk.arx-2027.props, crx.props

适用场景

  • 开发者想在 VS 2026 中启动新的 AutoCAD 2027 ARX/DBX/CRX C++ 项目
  • 开发者想在现有项目中添加 Jig、Reactor、Custom Object 或其他类
  • 传统 VS 向导(File → New → Project → ObjectARX)无法使用(VS 2026 回归问题 — 参见 MS Developer Community #11071541)

向导类型

用户说……要运行的脚本
"ARX app", "new plugin", "create project"New-ArxApp.ps1
"custom object", "custom entity", "AcDbEntity subclass"New-ArxCustomObject.ps1
"reactor", "database reactor", "entity reactor"New-ArxReactors.ps1
"jig", "AcEdJig", "interactive input"New-ArxJig.ps1
"MFC dialog", "palette", "dockbar", "MFC class"New-ArxMFCSupport.ps1
".NET wrapper", "managed wrapper", "C++/CLI"New-ArxNETWrapper.ps1
"COM wrapper", "ATL object", "IDispatch"New-ArxComWrapper.ps1
"dynamic property", "AcDbDynBlockReference", "dynprop"New-ArxDynProp.ps1

操作流程

步骤 1 — 确定 Skill 根目录

解析此 SKILL.md 所在目录的绝对路径。 所有脚本位于:<skill-root>\scripts\


步骤 2 — 确定向导类型

将用户意图映射到上述 8 种向导类型之一。如果不明确,请询问:

"你需要哪种向导?新的 ARX/DBX/CRX 项目,还是附加类(Jig、Reactor、Custom Object、MFC、.NET Wrapper、COM Wrapper、Dynamic Property)?"


步骤 3 — 收集参数

仅询问缺失的必填参数。除非用户提及,否则不要询问可选参数。

New-ArxApp — 完整项目
参数必填值缺失时询问
-ProjectName是有效的 C++ 标识符"项目名称是什么?"
-OutputPath是文件夹路径"应在哪里创建项目?"
-AppType否arx / dbx / crx默认值:arx(如果用户不确定则询问)
-MfcMode否none / shared / ext默认值:none
-UseAtl否开关仅在用户提及 COM 时询问
-UseDotNet否开关仅在用户提及 .NET 或 CLR 时询问
-RdsPrefix否3 个字母的符号默认值:Adk
New-ArxCustomObject — 自定义实体
参数必填默认值
-ClassName是—
-OutputPath是—
-BaseClass否AcDbEntity
-Protocols否2(Object + Entity)
-ProjectName否MyProject
New-ArxReactors — Reactor
参数必填备注
-ClassName是—
-ReactorType是参见下方的 Reactor 类型列表
-OutputPath是—
-ProjectName否MyProject

常见 Reactor 类型:AcDbDatabaseReactor、AcDbObjectReactor、AcDbEntityReactor、 AcEdInputContextReactor、AcApDocManagerReactor、AcDbLayoutManagerReactor、 AcDbAnnotationScaleReactor、AcDMMReactor

New-ArxJig — Jig 类
参数必填默认值
-ClassName是—
-OutputPath是—
-ObjectName否AcDbEntity
-NumberOfInputs否1
-ProjectName否MyProject
New-ArxMFCSupport — MFC 类
参数必填默认值
-ClassName是—
-OutputPath是—
-MfcType否Dialog
-IddDialog否IDD_DIALOG1
-ProjectName否MyProject

MFC 类型:Dialog、ChildDialog、TabDialog、Palette、PaletteSet、 DockControlBar、Control、FileDialog、FileNavDialog、 FieldDialog、FieldFormatDialog、FieldOptionDialog

New-ArxNETWrapper — 托管包装器
参数必填默认值
-WrapperName是—
-OutputPath是—
-CustomObjectName否AcDbEntity
-CompanyNamespace否Autodesk
-ObjectNamespace否AutoCAD
-ManagedDerivation否Entity
-ProjectName否MyProject
New-ArxComWrapper — ATL COM 包装器
参数必填默认值
-ShortName是—
-OutputPath是—
-ConnectionPoints否开关
-InterfaceDual否开关
-ProjectName否MyProject
New-ArxDynProp — 动态属性
参数必填默认值
-ClassName是—
-OutputPath是—
-InterfaceName否根据 ClassName 派生
-ConnectionPoints否开关
-ProjectName否MyProject

步骤 4 — 运行脚本

在 PowerShell 终端中运行 <skill-root>\scripts\ 下的相应脚本。

完整 ARX 项目示例:

& powershell.exe -ExecutionPolicy Bypass -NoProfile -File "<skill-root>\scripts\New-ArxApp.ps1" `
    -ProjectName MyPlugin `
    -OutputPath  "C:\Dev" `
    -AppType     arx `
    -MfcMode     shared

Jig 插件示例:

& powershell.exe -ExecutionPolicy Bypass -NoProfile -File "<skill-root>\scripts\New-ArxJig.ps1" `
    -ClassName      CMyJig `
    -ObjectName     AcDbLine `
    -NumberOfInputs 2 `
    -ProjectName    MyPlugin `
    -OutputPath     "C:\Dev\MyPlugin"

步骤 5 — 确认输出

脚本运行后,列出输出文件夹中的内容以确认生成结果:

Get-ChildItem "C:\Dev\MyPlugin" | Select-Object Name, Length

向用户报告文件列表,并说明后续步骤:

对于 New-ArxApp:

"项目已创建于 C:\Dev\MyPlugin\MyPlugin.vcxproj。在 Visual Studio 2026 中打开它。检查 Autodesk.arx-2027.props 中的 ObjectARX SDK 路径,然后选择 Build → x64 Debug。"

对于插件向导:

"已在 OutputPath 中生成 ClassName.h 和 ClassName.cpp。在 Visual Studio 中:右键单击项目 → Add → Existing Item → 选择这些文件。"


故障排除

问题解决方法
Destination already exists选择其他 -OutputPath,或先删除现有文件夹
ReactorType not found运行 Get-ChildItem <skill-root>\templates\reactors\*_tmpl.h | ForEach-Object { $_.Name -replace '_tmpl\.h$','' } 查看完整列表
构建错误:Cannot open include file 'acdb.h'设置 ARXSDK 环境变量,或编辑 Autodesk.arx-2027.props,使其指向 ObjectARX 2027 SDK
.NET 包装器中的 CLRSupport 错误确保项目的 .vcxproj 中包含 <CLRSupport>NetCore</CLRSupport>
VS 2026 向导仍不可用本技能可替代它 — 忽略有问题的 File→New 向导,改用本技能。

脚手架生成后的构建配置参考

生成项目脚手架后,开发者(或你这个 AI Agent)将继续编写插件代码。在协助设置构建选项、选择库、设置预处理器定义或诊断链接器/运行时错误时,请阅读 <skill-root>/docs/arx-dev-guide.md。其中涵盖:

  • 必需的编译器标志(/MD、/EHsc、/GR 等)以及每项标志的重要原因
  • 属性表继承链(rxsdk_common → debug/release → dbx/arx/crx)
  • 每种项目类型(DBX、ARX、CRX)和可选 API(B-Rep、AEC Modeler)应链接的 .lib 文件
  • Debug 与 Release 配置的差异
  • 常见问题 — 尤其是 /MD 与 /MDd 的规则(AutoCAD 始终是 Release 二进制文件;即使在 Debug 中,插件也必须使用 /MD)

重要规则: AutoCAD 以 Release 版本发布。插件 DLL 必须始终使用 /MD(MultiThreadedDLL)链接,绝不能使用 /MDd。使用 /MDd 会导致 CRT 不匹配、堆损坏和崩溃。只有在 Autodesk 内部 Debug 版本的 AutoCAD 中,/MDd 才有效。


实战经验

<skill-root>/docs/learnings.md 是一份持续更新的 wiki,记录了实际使用中遇到的问题:VS 2026 + MFC + ARX SDK 2027 构建陷阱、DllMain 冲突、MFC 模块状态规则和脚手架生成细节。遇到以下情况时请阅读:

  • 诊断看起来与 CRT/STL/RTC 不匹配有关的构建/链接错误
  • 使用 MFC 共享模式时,脚手架生成的项目首次构建失败
  • 添加新模板时,将 learnings.md 中任何新近验证的修复方案同步到本技能的模板文件中,以便后续生成的脚手架也能应用这些修复。

评论

支持 Markdown