Guía de inicio rápido del SDK de Altium Designer
El SDK de Altium Designer le permite crear extensiones personalizadas que se integran directamente en Altium Designer, añadiendo comandos, automatizando flujos de trabajo y accediendo a los datos de diseño mediante una API .NET administrada.
Esta guía le explica cómo instalar las herramientas de desarrollo, crear un proyecto de extensión, añadir un comando y ejecutarlo dentro de Altium Designer.
Requisitos previos
-
Registro en Altium Developer Center – necesario para habilitar el acceso al SDK de Altium Designer y sus extensiones
-
Altium Designer instalado y con licencia
-
Un IDE compatible con .NET (Visual Studio o VS Code con compatibilidad para C#)
Paso 1: Instalar la extensión Altium Developer
La extensión Altium Developer añade plantillas de proyecto y herramientas del SDK directamente en Altium Designer.
-
En Altium Designer, vaya a Extensions and Updates → Available.
-
En la sección Software Extensions , busque Altium Developer.
-
Instale la extensión y, cuando se le solicite, reinicie Altium Designer.
Paso 2: Crear un nuevo proyecto de extensión
-
En Altium Designer, vaya a File → New → Other → Extension.
-
Extension ID:
ShowNetsExtension -
Extension Kind:
Altium Designer Server -
Development Language:
C# -
IDE Version:
latest -
SDK Version:
latest
-
-
Una vez creada la extensión, Altium Designer muestra sus detalles. Tenga en cuenta la Source Location — abra el archivo
.csprojde esa ruta en su IDE.
Paso 3: Añadir su primer comando
Abra Source Code\Commands.cs y añada 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();
}
Abra Source Code\Main.cs y registre el comando en la clase PluginServerModule:
protected override void InitializeCommands()
{
((CommandLauncher)CommandLauncher).RegisterCommand("ShowNets", Commands.Command_ShowNets, Commands.GetState_ShowNets);
}
Compile el proyecto para instalar la extensión.
Paso 4: Ejecutar su comando en Altium Designer
-
Inicie Altium Designer.
-
Haga clic con el botón derecho en cualquier barra de herramientas y seleccione Customize…
-
Bajo Commands, haga clic en New… y configure lo siguiente:
-
Process:
ShowNetsExtension:ShowNets -
Caption:
ShowNets
-
-
Arrastre el nuevo comando a una barra de herramientas.
-
Haga clic en el comando: debería aparecer un cuadro de diálogo con una lista de redes.
Pasos siguientes
-
Consulte la documentación del Altium Designer SDK para ver interfaces que cubren esquemáticos, diseño PCB, componentes y más.
-
Explore ejemplos de extensiones y demostraciones en la organización de GitHub AltiumDeveloper.