Altium Designer SDK 빠른 시작 가이드
개요
- SDK 확장 기능 개발에 필요한 사전 요구 사항과 설정 단계를 알아봅니다.
- Altium Designer 내에서 “Net 표시” 명령을 구현하고 등록한 후 실행하는 방법을 배웁니다.
- 다음 확장 기능 개발에 활용할 명령줄 템플릿과 참고 자료를 찾아봅니다.
Altium Designer SDK를 사용하면 Altium Designer에 직접 통합되는 사용자 지정 확장 기능을 개발할 수 있습니다. 관리형 .NET API를 통해 명령을 추가하고, 워크플로를 자동화하고, 설계 데이터에 액세스할 수 있습니다.
이 가이드에서는 개발 도구 설치, 확장 기능 프로젝트 생성, 명령 추가, Altium Designer 내 실행 과정을 안내합니다.
사전 요구 사항
-
Altium Developer Center 가입 – Altium Designer SDK 및 확장 기능에 대한 액세스 권한을 얻는 데 필요
-
Altium Designer 설치 및 라이선스 활성화
-
.NET 호환 IDE(Visual Studio 또는 C#을 지원하는 VS Code)
1단계: Altium Developer 확장 기능 설치
Altium Developer 확장 기능은 프로젝트 템플릿과 SDK 도구를 Altium Designer에 직접 추가합니다.
-
Altium Designer에서 Extensions and Updates → Available(으)로 이동합니다.
-
Software Extensions 섹션에서 Altium Developer을(를) 검색합니다.
-
확장 기능을 설치한 다음, 메시지가 표시되면 Altium Designer를 다시 시작합니다.
2단계: 새 확장 기능 프로젝트 생성
-
Altium Designer에서 File → New → Other → Extension(으)로 이동합니다.
-
Extension ID:
ShowNetsExtension -
Extension Kind:
Altium Designer Server -
Development Language:
C# -
IDE Version:
latest -
SDK Version:
latest
-
-
확장 기능이 생성되면 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에서 명령 실행
-
Altium Designer를 시작합니다.
-
아무 도구 모음이나 마우스 오른쪽 버튼으로 클릭한 다음 선택합니다. Customize…
-
Commands에서 New…을(를) 클릭하고 다음과 같이 구성합니다.
-
Process:
ShowNetsExtension:ShowNets -
Caption:
ShowNets
-
-
새 명령을 도구 모음으로 드래그합니다.
-
명령을 클릭하면 Net 목록이 있는 대화 상자가 나타납니다.
다음 단계
-
Altium Designer SDK 참조 문서에서
SCH,PCB,EDP,DXP,ComponentLib및Embedded네임스페이스의 전체 .NET API를 살펴보세요. -
API 규칙을 읽고 진입점, GetState/SetState 메서드 및 열거형이 어떻게 구성되어 있는지 알아보세요.
-
Altium Designer Extension Template으로 다음 확장 기능 개발을 시작하고, Altium Designer 실행 중에 핫 리로드를 활용하세요.