Guía de inicio rápido del SDK de Altium Designer

De un vistazo

Crea tu primera extensión personalizada para Altium Designer con esta guía paso a paso del SDK. Sigue el proceso desde la configuración de las herramientas de desarrollo y la creación de un proyecto en C# hasta la incorporación y ejecución de un comando que muestra los nombres de las redes de un esquema o proyecto. También encontrarás una opción de plantilla de línea de comandos con recarga en caliente. Sigue leyendo para dar tus primeros pasos en el desarrollo de extensiones para Altium Designer.

- Conoce los requisitos previos y los pasos de configuración para desarrollar extensiones con el SDK.
- Aprende a implementar, registrar y ejecutar un comando «Mostrar redes» en Altium Designer.
- Encuentra la plantilla de línea de comandos y los recursos de referencia para tu próxima extensión.
Profundiza con IA:

El SDK de Altium Designer se encuentra actualmente en fase beta cerrada y solo está disponible para unos pocos clientes seleccionados con acceso anticipado.

El SDK de Altium Designer te permite crear extensiones personalizadas que se integran directamente en Altium Designer para añadir comandos, automatizar flujos de trabajo y acceder a los datos de diseño mediante una API .NET administrada.

Esta guía te explica cómo instalar las herramientas de desarrollo, crear un proyecto de extensión, añadir un comando y ejecutarlo en Altium Designer.

Prefer the command line? La plantilla de extensión de Altium Designer crea una extensión completa en C# con un comando, sin necesidad del asistente integrado en la aplicación ni de Visual Studio, y 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"

requiere Altium Designer 24 o posterior y .NET SDK 8 o posterior (.NET SDK 10 para Altium Designer 26.12 y posteriores). El código del comando que aparece en Step 3 a continuación funciona de la misma manera en un proyecto basado en una plantilla.

Requisitos previos

Paso 1: Instalar la extensión Altium Developer

La extensión Altium Developer añade plantillas de proyecto y herramientas del SDK directamente a Altium Designer.

  1. En Altium Designer, ve a Extensions and Updates → Available.

  2. En la sección Software Extensions, busca Altium Developer.

  3. Instala la extensión y reinicia Altium Designer cuando se te solicite.

Paso 2: Crear un nuevo proyecto de extensión

  1. En Altium Designer, ve a File → New → Other → Extension.

    • Extension ID: ShowNetsExtension

    • Extension Kind: Altium Designer Server

    • Development Language: C#

    • IDE Version: latest

    • SDK Version: latest

  2. Una vez creada la extensión, Altium Designer muestra sus detalles. Toma nota de Source Location — abre el archivo .csproj de esa ruta en tu IDE.

Paso 3: Añadir tu primer comando

Abre Source Code\Commands.cs y añade los siguientes métodos a la clase 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();
    }

Los tipos utilizados aquí (IProject, IDocument  y DXP.GlobalVars ) están documentados en la Referencia del SDK de Altium Designer.

Abre Source Code\Main.cs y registra el comando en la clase PluginServerModule:

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

Compila el proyecto para instalar la extensión.

Paso 4: Ejecutar tu comando en Altium Designer

  1. Inicia Altium Designer.

  2. Haz clic con el botón derecho en cualquier barra de herramientas y selecciona Customize…

  3. En Commands, haz clic en New… y configura lo siguiente:

    • Process: ShowNetsExtension:ShowNets

    • Caption: ShowNets

  4. Arrastra el nuevo comando a una barra de herramientas.

  5. Haz clic en el comando: debería aparecer un cuadro de diálogo con una lista de redes.

Próximos pasos

AI-LocalizedLocalizado por IA
Si encuentra un problema, seleccione el texto/imagen y presioneCtrl + Enterpara enviarnos sus comentarios.
Contents
Contents