acad-dotnet について
acad-dotnetは、AutoCAD .NETプラグインを一貫して作成するためのエージェントスキルです。AutoCAD、Civil 3D、Plant 3D向けの開発者を対象に、プロジェクトの作成、設定、ビルド、デスクトップおよびヘッドレステスト、パッケージ化を扱います。
主な機能
- 01対象製品に応じたテンプレートと依存関係の選択
- 02.NETターゲットフレームワークとプラットフォームの設定
- 03起動プロファイルの作成とプラグインのビルド
- 04NETLOADまたはaccoreconsoleによるテスト
- 05デスクトップ用またはDesign Automation用バンドルの作成
活用シーン
- 01AutoCADまたはCivil 3Dプラグインプロジェクトの作成
- 02accoreconsoleを使ったローカルのヘッドレステスト
- 03デスクトップ読み込みまたはDesign Automation用バンドルの準備
MCP 対応
READMEにMCPの記載はありません。
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ autodesk-platform-services/ skills --skill acad-dotnetインストール後、Claude Code で/acad-dotnetを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
README.mdreferences/autocad-api.mdcivil3d-api.mdcode-sleuth.mdlearnings.mdplant3d-api.mdtemplates/acad/ClassName.csREADME.mdRootNamespace.csprojtemplates/acad/.template.config/template.jsontemplates/acad/RootNamespace.bundle/PackageContents.xmltemplates/acad/RootNamespace.bundle/Contents/.gitkeeptemplates/civil/.gitignoreLICENSEReadMe.mdtemplates/civil/Civil/CivilClassLib.csprojCmd.cstemplates/civil/Civil/.template.config/template.json詳細
スキャフォールドスキル — AutoCAD .NET プラグイン
新しいプラグインプロジェクトを最初から最後まで作成するためのエージェント向け手順です。以下の手順を順番に実行してください。 ここに記載されているすべての csproj パターンは、AutoCAD 2027 / .NET 10 で検証済みです。
Step 0 — 対象製品を特定する
| ユーザーの発言 | 対象 | テンプレート | 追加パッケージ |
|---|---|---|---|
| "AutoCAD plugin" / "acad add-in" | AutoCAD 2027 | acad | AutoCAD.NET 26.0.0 |
| "Civil 3D plugin" / "c3d add-in" | Civil 3D 2027 | civil | Civil3D.NET 13.9.628 |
| "Plant 3D plugin" / "plant add-in" | Plant 3D 2027 | (手動) | AutoCAD.NET.Core 26.0.0 + SDK DLL refs |
| "Design Automation" / "DA" | 任意(ヘッドレス) | acad | .Core + .Model のみを使用(AcMgd なし) |
Step 1 — スキャフォールド
AutoCAD
dotnet new acad -n <ProjectName> -o <ProjectName>
cd <ProjectName>
Civil 3D
dotnet new civil --rootNamespace=<ProjectName> -o <ProjectName>
cd <ProjectName>
Plant 3D(手動)
<ProjectName>/<ProjectName>.csproj を作成します — 詳細は以下の Plant 3D セクションを参照してください。
Step 2 — csproj を修正する(重要)
テンプレートでは、古い設定や誤った設定が生成される場合があります。以下の修正をすべて適用してください。
ターゲットフレームワーク
テンプレートで net8.0-windows または net6.0-windows が生成された場合は、net10.0-windows に変更します。
プラットフォームターゲット — RuntimeIdentifier より x64 を推奨
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PlatformTarget>x64</PlatformTarget>
理由: AutoCAD は出力先の直接のフォルダー内にアセンブリがあるかを検索します。RuntimeIdentifier は win-x64 サブフォルダーを作成しますが、AutoCAD/accoreconsole は既定ではそのフォルダーを検索しません。
例外: Oracle や SQLite など、クロスプラットフォームのネイティブ NuGet パッケージをインポートする場合は、正しい Windows バイナリを取得するために <RuntimeIdentifier>win-x64</RuntimeIdentifier> が必要です。このまれなケースでは、出力先がアクセスできないサブフォルダーに移動されないよう、csproj に <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> も追加してください。
GenerateTargetFrameworkAttribute
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
AutoCAD ホスト独自の TargetFramework 属性との競合を防ぎます。
csproj テンプレートの例 — DA / Civil 3D ヘッドレス
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
<Nullable>enable</Nullable>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
<PackageReference Include="AutoCAD.NET.Core" Version="26.0.0" ExcludeAssets="runtime" />
<PackageReference Include="AutoCAD.NET.Model" Version="26.0.0" ExcludeAssets="runtime" />
</ItemGroup>
</Project>
csproj テンプレートの例 — デスクトップのみ(UI あり)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
<Nullable>enable</Nullable>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
<PackageReference Include="AutoCAD.NET" Version="26.0.0" ExcludeAssets="runtime" />
</ItemGroup>
</Project>
Plant 3D csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<Nullable>enable</Nullable>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
<PackageReference Include="AutoCAD.NET.Core" Version="26.0.0" ExcludeAssets="runtime" />
<PackageReference Include="AutoCAD.NET.Model" Version="26.0.0" ExcludeAssets="runtime" />
</ItemGroup>
<ItemGroup>
<Reference Include="PnIDMgd">
<HintPath>$(PLANT_SDK)\PnIDMgd.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="PnPDataLinks">
<HintPath>$(PLANT_SDK)\PnPDataLinks.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="PnPDataObjects">
<HintPath>$(PLANT_SDK)\PnPDataObjects.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="PnPProjectManagerMgd">
<HintPath>$(PLANT_SDK)\PnPProjectManagerMgd.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="PnPCommonMgd">
<HintPath>$(PLANT_SDK)\PnPCommonMgd.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="PnPCommonDbxMgd">
<HintPath>$(PLANT_SDK)\PnPCommonDbxMgd.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="PnIdProjectPartsMgd">
<HintPath>$(PLANT_SDK)\PnIdProjectPartsMgd.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
</Project>
Directory.Build.props を使って PLANT_SDK を設定します。
<Project>
<PropertyGroup>
<PLANT_SDK Condition="'$(PLANT_SDK)'==''">D:\SDKS\Plant2027\inc-x64</PLANT_SDK>
</PropertyGroup>
</Project>
Step 3 — エントリーポイントの定型コード
App.cs を作成します(またはテンプレートによって生成されていることを確認します)。
using Autodesk.AutoCAD.Runtime;
[assembly: ExtensionApplication(typeof(<ProjectName>.App))]
[assembly: CommandClass(typeof(<ProjectName>.Commands))]
namespace <ProjectName>;
public class App : IExtensionApplication
{
public void Initialize() { }
public void Terminate() { }
}
Step 4 — launchSettings.json を追加する
Properties/launchSettings.json を作成します。<ACAD_HOME> を AutoCAD のインストールパスに置き換えてください。
AutoCAD
{
"profiles": {
"<ProjectName>": { "commandName": "Project" },
"AutoCAD2027": {
"commandName": "Executable",
"executablePath": "<ACAD_HOME>\\acad.exe"
}
}
}
Civil 3D
{
"profiles": {
"<ProjectName>": { "commandName": "Project" },
"C3D2027_Metric": {
"commandName": "Executable",
"executablePath": "<ACAD_HOME>\\acad.exe",
"commandLineArgs": "/ld \"<ACAD_HOME>\\AecBase.dbx\" /p \"<<C3D_Metric>>\" /product C3D /language en-US"
},
"C3D2027_Imperial": {
"commandName": "Executable",
"executablePath": "<ACAD_HOME>\\acad.exe",
"commandLineArgs": "/ld \"<ACAD_HOME>\\AecBase.dbx\" /p \"<<C3D_Imperial>>\" /product C3D /language en-US"
}
}
}
Plant 3D
{
"profiles": {
"<ProjectName>": { "commandName": "Project" },
"Plant3D2027": {
"commandName": "Executable",
"executablePath": "<ACAD_HOME>\\acad.exe",
"commandLineArgs": "/product PLNT3D /language \"en-US\""
}
}
}
Step 5 — ビルドして読み込む
dotnet build -c Debug
出力先:bin\Debug\net10.0-windows\<ProjectName>.dll
デスクトップ: AutoCAD で NETLOAD を使って DLL を読み込みます(Step 5a を参照)。
accoreconsole: SECURELOAD 0 の後に NETLOAD を実行する .scr スクリプトを使うか、/al を使います(Step 6 を参照)。
Step 5a — デスクトップ UI のテスト(NETLOAD)
初回の読み込み
- launchSettings プロファイルを使うか、直接 AutoCAD(または Civil 3D / Plant 3D)を起動します
- コマンドラインで
NETLOADを実行します bin\Debug\net10.0-windows\<ProjectName>.dllを指定します- コマンド(例:
MYCOMMAND)を実行します
SECURELOAD の処理
AutoCAD では既定で SECURELOAD=1 が設定されており、信頼されていないパスの DLL はブロックされます。次の方法があります。
| 方法 | 使用する場面 |
|---|---|
コマンドラインで SECURELOAD 0 | 手早く一度だけテストする場合 — セッションごとにリセットされます |
TRUSTEDPATHS システム変数 | ビルド出力フォルダーを信頼済みリストに追加します(レジストリに保存されます) |
TRUSTEDLOCATIONS ダイアログ | TRUSTEDPATHS の UI 版 — Settings > Files > Trusted Locations |
プログラムから信頼済みパスを追加するには、次のようにします。
TRUSTEDPATHS
既存の値に ;C:\your\build\output\path を追加します。
起動時に自動読み込みする(ApplicationPlugins バンドルを使わない場合)
繰り返しテストする場合は、起動のたびに NETLOAD を入力せずに済むようにします。Startup Suite に追加してください。
APPLOADコマンドを実行します- Startup Suite の下にある "Contents..." をクリックします
- DLL を追加します
または、サポートパスにある acad.lsp / acaddoc.lsp を使います。
;; acaddoc.lsp — runs on every document open
(command "NETLOAD" "C:\\path\\to\\Plugin.dll")
Visual Studio / VS Code でのデバッグ
launchSettings.json を設定した状態で(手順 4):
- コードにブレークポイントを設定します
- デバッグを開始します(F5)— 選択したプロファイルで AutoCAD が起動します
- AutoCAD で DLL を
NETLOADし、コマンドを実行します - VS でブレークポイントに到達します
プロセスにアタッチする場合(AutoCAD がすでに実行中の場合):
- デバッグ > プロセスにアタッチ >
acad.exeを選択します
手順 6 — accoreconsole によるローカルテスト(ヘッドレス)
方法 A:スクリプト経由で NETLOAD
.scr スクリプトファイルを作成します:
SECURELOAD
0
NETLOAD
C:\full\path\to\Plugin.dll
MYCOMMAND
起動します:
accoreconsole.exe /i "drawing.dwg" /s "test.scr" /ld "AecBase.dbx" /product C3D /language en-US
方法 B:.bundle を使った /al(推奨)
DA の動作により近い方法です。次の構成でバンドルフォルダーを作成します:
TestBundle/
<ProjectName>.bundle/
PackageContents.xml
Contents/
<ProjectName>.dll
<ProjectName>.deps.json
.scr に必要なのはコマンドだけです(SECURELOAD/NETLOAD は不要です):
MYCOMMAND
起動します:
accoreconsole.exe /i "drawing.dwg" /al "TestBundle" /s "test.scr" /isolate user1 "D:\Tmp" /ld "AecBase.dbx" /product C3D /language en-US
ルール:
/alには.bundleフォルダー自体ではなく、その親フォルダーを指定します- 作業ディレクトリへのレジストリ書き込みを防ぐため、必ず
/isolateを使用してください - フラグの詳細については
autocad-api.mdを参照してください。
手順 7 — ApplicationPlugins バンドル(デスクトップでの自動読み込み)
デスクトップへのデプロイ(DA 以外)では、次のいずれかのパスに .bundle フォルダーを配置します:
| パス | 適用範囲 | 管理者権限が必要 |
|---|---|---|
%APPDATA%\Autodesk\ApplicationPlugins\ | 現在のユーザー | いいえ |
C:\Program Files\Autodesk\ApplicationPlugins\ | すべてのユーザー | はい |
AutoCAD は起動時にこれらのパスをスキャンし、有効な PackageContents.xml を含む .bundle を読み込みます。
.NET プラグイン用の最小バンドル
%APPDATA%\Autodesk\ApplicationPlugins\
<ProjectName>.bundle/
PackageContents.xml
Contents/
<ProjectName>.dll
<ProjectName>.deps.json
コマンド登録を含む PackageContents.xml
<?xml version="1.0" encoding="utf-8" ?>
<ApplicationPackage SchemaVersion="1.0" Version="1.0.0"
ProductCode="{generate-new-guid}"
Name="<ProjectName>"
Description="..."
Author="...">
<CompanyDetails Name="..." Url="..." Email="..." />
<RuntimeRequirements
Platform="AutoCAD"
SeriesMin="R26.0" SeriesMax="R26.0"
OS="Win64" />
<Components Description="plugin">
<RuntimeRequirements
SupportPath="./Contents"
Platform="AutoCAD"
SeriesMin="R26.0" SeriesMax="R26.0"
OS="Win64" />
<ComponentEntry
AppName="<ProjectName>"
AppType=".NET"
Version="1.0.0"
ModuleName="./Contents/<ProjectName>.dll"
AppDescription="..."
LoadOnAutoCADStartup="True"
LoadOnCommandInvocation="False">
<Commands GroupName="<ProjectName>_Commands">
<Command Local="MYCOMMAND" Global="MYCOMMAND" />
</Commands>
</ComponentEntry>
</Components>
</ApplicationPackage>
主な属性:
Platform:AutoCAD(基本)、Civil3D、Plant3D、またはパイプ区切りのAutoCAD|Civil3DSeriesMin/SeriesMax:R26.0= 2027、R25.1= 2026、R25.0= 2025LoadOnAutoCADStartup="True":起動時に DLL をすぐに読み込みますLoadOnCommandInvocation="True"+LoadOnAutoCADStartup="False":遅延読み込み(コマンドが呼び出されたときのみ)SupportPath="./Contents":Contents フォルダーを AutoCAD のサポートファイル検索パスに追加します<Commands>:AutoCAD がオンデマンドで読み込むバンドルを認識できるよう、コマンドを登録します
バンドルをローカルにデプロイするビルドスクリプト
$BundleName = "<ProjectName>"
$BuildOut = "bin\Debug\net10.0-windows"
$BundleDest = "$env:APPDATA\Autodesk\ApplicationPlugins\$BundleName.bundle"
# Create bundle structure
New-Item "$BundleDest\Contents" -ItemType Directory -Force | Out-Null
Copy-Item "PackageContents.xml" "$BundleDest\" -Force
Copy-Item "$BuildOut\$BundleName.dll" "$BundleDest\Contents\" -Force
Copy-Item "$BuildOut\$BundleName.deps.json" "$BundleDest\Contents\" -Force
Write-Host "Deployed to: $BundleDest"
デプロイ後に AutoCAD を再起動します。バンドルは自動的に読み込まれます。
手順 8 — DA バンドルのパッケージ化
PackageContents.xml
<?xml version="1.0" encoding="utf-8" ?>
<ApplicationPackage SchemaVersion="1.0" Version="1.0.0"
ProductCode="{generate-new-guid}"
Name="<ProjectName>"
Description="..."
Author="...">
<CompanyDetails Name="..." Url="..." Email="..." />
<Components Description="plugin">
<RuntimeRequirements
SeriesMin="R26.0" SeriesMax="R26.0"
Platform="AutoCAD"
OS="Win64" />
<ComponentEntry
AppName="<ProjectName>"
Version="1.0.0"
ModuleName="./Contents/<ProjectName>.dll"
AppDescription="..."
LoadOnAutoCADStartup="True"
LoadOnCommandInvocation="False" />
</Components>
</ApplicationPackage>
SeriesMin/SeriesMax: R26.0 = AutoCAD 2027 です。DA エンジンのバージョンと一致させる必要があります。
バンドルフォルダーの構成
<ProjectName>.bundle/
PackageContents.xml
Contents/
<ProjectName>.dll
<ProjectName>.deps.json
正しく ZIP 化する(重要)
# CORRECT — bundle folder is zip root
Compress-Archive -Path "$ProjectName.bundle" -DestinationPath "$ProjectName.zip"
# WRONG — puts PackageContents.xml at zip root; bundle silently not loaded
Compress-Archive -Path "$ProjectName.bundle\*" -DestinationPath "$ProjectName.zip"
DA Activity の commandLine
$(engine.path)\accoreconsole.exe /i "$(args[inputFile].path)" /al "$(appbundles[<BundleName>].path)" /s "$(settings[script].path)"
/alは親フォルダーから .bundle を読み込みます(ローカルでの使用方法は以下を参照)/sはコマンド呼び出しを含むスクリプトを渡します
accoreconsole で /al をローカル使用する(非公式)
/al はデスクトップ版 accoreconsole でも動作します。ただし、公式ドキュメントには記載されていません。引数には .bundle ディレクトリを含む親フォルダーを指定します:
TestFolder/
MyPlugin.bundle/
PackageContents.xml
Contents/
MyPlugin.dll
起動します:
accoreconsole.exe /i "drawing.dwg" /al "D:\TestFolder" /s "test.scr" /isolate user1 "D:\Tmp"
ルール:
/alには.bundleフォルダー自体ではなく、その親フォルダーを指定します- 必ず
/isolateを使用してください。使用しない場合、/alは親フォルダーにレジストリエントリを書き込み、作業ディレクトリを汚染します /isolate user1 <tempDir>を指定すると、これらのレジストリ書き込み先が一時ディレクトリに変更されます/alを使用する場合、.scrスクリプトでSECURELOAD 0やNETLOADを実行する必要はありません。バンドルは自動的に読み込まれます
DA エンジン ID(. ではなく + を使用)
| 製品 | エンジン ID |
|---|---|
| AutoCAD 2027 | Autodesk.AutoCAD+26_0 |
| AutoCAD 2026 | Autodesk.AutoCAD+25_1 |
| AutoCAD 2025 | Autodesk.AutoCAD+25_0 |
検証済みビルド出力パス
正しい csproj 設定で dotnet build -c Debug を実行した後:
bin\Debug\net10.0-windows\<ProjectName>.dll ← load this
bin\Debug\net10.0-windows\<ProjectName>.deps.json
bin\Debug\net10.0-windows\<ProjectName>.pdb
bin\Debug\net10.0-windows\win-x64\ サブフォルダーが表示される場合、csproj に適切なオーバーライドのない RuntimeIdentifier が設定されています。これを削除して PlatformTarget を使用するか、<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> を設定してください。