Guia de Início Rápido do SDK do Altium Designer
O SDK do Altium Designer permite criar extensões personalizadas que se integram diretamente ao Altium Designer – adicionando comandos, automatizando fluxos de trabalho e acessando dados de projeto por meio de uma API .NET gerenciada.
Este guia orienta você na instalação das ferramentas de desenvolvimento, na criação de um projeto de extensão, na adição de um comando e em sua execução dentro do Altium Designer.
Pré-requisitos
-
Cadastro no Altium Developer Center – necessário para desbloquear o acesso ao SDK do Altium Designer e às suas extensões
-
Altium Designer instalado e licenciado
-
Uma IDE compatível com .NET (Visual Studio ou VS Code com suporte a C#)
Etapa 1: Instale a extensão Altium Developer
A extensão Altium Developer adiciona modelos de projeto e ferramentas do SDK diretamente ao Altium Designer.
-
No Altium Designer, vá para Extensions and Updates → Available.
-
Na seção Software Extensions , pesquise por Altium Developer.
-
Instale a extensão e, em seguida, reinicie o Altium Designer quando solicitado.
Etapa 2: Crie um novo projeto de extensão
-
No Altium Designer, vá para File → New → Other → Extension.
-
Extension ID:
ShowNetsExtension -
Extension Kind:
Altium Designer Server -
Development Language:
C# -
IDE Version:
latest -
SDK Version:
latest
-
-
Depois que a extensão for criada, o Altium Designer exibirá seus detalhes. Observe o Source Location — abra o arquivo
.csprojdesse caminho em sua IDE.
Etapa 3: Adicione seu primeiro comando
Abra Source Code\Commands.cs e adicione os métodos a seguir à classe 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 e registre o comando na classe PluginServerModule:
protected override void InitializeCommands()
{
((CommandLauncher)CommandLauncher).RegisterCommand("ShowNets", Commands.Command_ShowNets, Commands.GetState_ShowNets);
}
Compile o projeto para instalar a extensão.
Etapa 4: Execute seu comando no Altium Designer
-
Inicie o Altium Designer.
-
Clique com o botão direito em qualquer barra de ferramentas e selecione Customize…
-
Em Commands, clique em New… e configure o seguinte:
-
Process:
ShowNetsExtension:ShowNets -
Caption:
ShowNets
-
-
Arraste o novo comando para uma barra de ferramentas.
-
Clique no comando – uma caixa de diálogo com a lista de nets deverá aparecer.
Próximas etapas
-
Consulte a documentação do Altium Designer SDK para interfaces que abrangem esquemáticos, layout de PCB, componentes e muito mais.
-
Explore extensões de exemplo e demonstrações na organização GitHub AltiumDeveloper.