Altium Designer SDK クイックスタートガイド

Altium Designer SDKは現在クローズドベータ版であり、選定された一部の早期アクセスのお客様のみが利用できます。

Altium Designer SDKを使用すると、Altium Designerに直接統合されるカスタム拡張機能を開発できます。マネージド.NET APIを通じて、コマンドの追加、ワークフローの自動化、設計データへのアクセスが可能です。

このガイドでは、開発ツールのインストール、拡張機能プロジェクトの作成、コマンドの追加、Altium Designer内での実行までを順を追って説明します。

Prefer the command line? Altium Designer Extension Template を使用すると、アプリ内ウィザードやVisual Studioを使わずに、コマンドを1つ備えた完全なC#拡張機能を作成できます。hot-reloads your code while Altium Designer keeps running.

dotnet new install Altium.Designer.Extension.Templates
dotnet new ad-extension -n MyTools --altium-system-dir "C:\Program Files\Altium\AD26\System"

Altium Designer 24以降と.NET SDK 8以降(Altium Designer 26.12以降では.NET SDK 10)が必要です。以下のStep 3のコマンドコードは、テンプレートベースのプロジェクトでも同じように動作します。

前提条件

  • Altium Developer Center への登録 – Altium Designer SDKとその拡張機能へのアクセスを有効にするために必要です

  • Altium Designer がインストールされ、ライセンスが有効であること

  • .NET対応のIDE(Visual Studio、またはC#をサポートするVS Code)

ステップ1:Altium Developer拡張機能をインストールする

Altium Developer拡張機能は、プロジェクトテンプレートとSDKツールをAltium Designerに直接追加します。

  1. Altium Designerで、Extensions and Updates → Availableに移動します。

  2. Software Extensions セクションで、Altium Developerを検索します。

  3. 拡張機能をインストールし、指示に従ってAltium Designerを再起動します。

ステップ2:新しい拡張機能プロジェクトを作成する

  1. Altium Designerで、File → New → Other → Extensionに移動します。

    • Extension ID: ShowNetsExtension

    • Extension Kind: Altium Designer Server

    • Development Language: C#

    • IDE Version: latest

    • SDK Version: latest

  2. 拡張機能を作成すると、Altium Designerにその詳細が表示されます。Source Location を確認し、そのパスにある.csproj ファイルをIDEで開きます。

ステップ3:最初のコマンドを追加する

Source Code\Commands.csを開き、Commands クラスに次のメソッドを追加します。

    /// <summary>
    /// Determines the enabled/visible state for the "Show Nets" command in Altium Designer.
    /// </summary>
    /// <param name="argContext">The current server document view context.</param>
    /// <param name="argParameters">Command parameters (unused).</param>
    /// <param name="argEnabled">Set to true if the command should be enabled.</param>
    /// <param name="argChecked">Set to true if the command should appear checked (unused).</param>
    /// <param name="argVisible">Set to true if the command should be visible (unused).</param>
    /// <param name="argCaption">Command caption (unused).</param>
    /// <param name="argImageFile">Command image file (unused).</param>
    public static void GetState_ShowNets(IServerDocumentView argContext, ref string argParameters, ref bool argEnabled,
        ref bool argChecked, ref bool argVisible, ref string argCaption, ref string argImageFile)
    {
        // Retrieve the currently focused project from Altium Designer's workspace.
        var project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject() as IProject;

        // If the project needs to be compiled (e.g., netlist out of date), compile it.
        if (project?.DM_NeedsCompile() == true)
            project.DM_Compile();

        // Enable the command only if a valid project is focused and it's not the "Free Documents" project.
        argEnabled = project != null && !IsFreeDocumentsProject(project);
    }

    /// <summary>
    /// Command handler to display all net names in the current schematic document or project.
    /// </summary>
    /// <param name="view">The current server document view.</param>
    /// <param name="parameters">Command parameters (unused).</param>
    public static void Command_ShowNets(IServerDocumentView view, ref string parameters)
    {
        // Get the currently focused project from Altium Designer.
        var project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject() as IProject;
        if (project == null || IsFreeDocumentsProject(project))
            return;

        string documentName;
        // Get the currently focused document (e.g., schematic sheet).
        var document = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument() as IDocument;
        if (document == null)
        {
            // If no document is focused, ensure the project is compiled and use the flattened project document.
            if (project.DM_NeedsCompile()) project.DM_Compile();
            document = project.DM_DocumentFlattened();
            documentName = "Project";
        }
        else
        {
            // Only proceed if the focused document is a schematic (DocKindSch).
            if (document.DM_DocumentKind() != EDPConstant.DocKindSch) return;
            documentName = document.DM_FileName();
        }

        // Enumerate all nets in the document, retrieve their full names, and sort them alphabetically.
        var netNames = Enumerable.Range(0, document.DM_NetCount())
            .Select(document.DM_Nets)
            .Select(net => net.DM_FullNetName())
            .OrderBy(name => name);

        // Display the list of net names in an information dialog within Altium Designer.
        DXP.Utils.ShowInfo(string.Join(Environment.NewLine, netNames), $"Nets [{documentName}]");
    }

    /// <summary>
    /// Checks if the given project is the special "Free Documents" project in Altium Designer.
    /// </summary>
    /// <param name="project">The project to check.</param>
    /// <returns>True if the project is the Free Documents project; otherwise, false.</returns>
    private static bool IsFreeDocumentsProject(IProject project)
    {
        return project == DXP.GlobalVars.DXPWorkSpace.DM_FreeDocumentsProject();
    }

ここで使用する型(IProject、 IDocument 、DXP.GlobalVars )については、Altium Designer SDKリファレンスで説明しています。

Source Code\Main.cs を開き、PluginServerModuleクラスにコマンドを登録します。

protected override void InitializeCommands()
{
    ((CommandLauncher)CommandLauncher).RegisterCommand("ShowNets", Commands.Command_ShowNets, Commands.GetState_ShowNets);
}

プロジェクトをビルドして、拡張機能をインストールします。

ステップ4:Altium Designerでコマンドを実行する

  1. Altium Designerを起動します。

  2. 任意のツールバーを右クリックして、次を選択します。Customize…

  3. Commandsで、New… をクリックし、次のように設定します。

    • Process: ShowNetsExtension:ShowNets

    • Caption: ShowNets

  4. 新しいコマンドをツールバーにドラッグします。

  5. コマンドをクリックすると、ネットの一覧を含むダイアログが表示されます。

次のステップ

  • Altium Designer SDKリファレンスを参照してください。SCH、PCB、EDP、DXP、ComponentLib、Embeddedの各名前空間の.NET API全体を網羅しています。

  • API規約 を読み、エントリポイント、GetState/SetStateメソッド、列挙型がどのように構成されているかを確認してください。

  • 次の拡張機能は、Altium Designer Extension Templateを使って作成してください。Altium Designerの実行中にホットリロードを利用できます。

AI-LocalizedAI で翻訳
問題が見つかった場合、文字/画像を選択し、Ctrl + Enter キーを押してフィードバックをお送りください。
Contents
Contents