Delphi SDK のハウツー FAQ
Altium Designer の SDK コーディングに関する、よくある質問をご覧ください。
SDK API の詳細については、Altium Designer SDK Reference を参照してください。
System
Altium Designer SDK のシステム要件は何ですか?
Altium SDK を使用して Altium Designer 向けのソフトウェア拡張機能を開発するには、Embarcadero Delphi XE2 以降、SDK、そして Altium Designer 13 以降が必要です。Altium Designer のソフトウェア拡張機能のビルドには、比較的新しい Delphi の各エディションを利用できます。Embarcadero Delphi Starter edition(低コストな選択肢)、Professional edition、Enterprise、Architect、Ultimate edition はいずれも Altium SDK で問題なく動作します。
Altium Designer SDK 自体は、3 つの主要な API で構成されています。DXP(Electronic Data Platform API ユニット群)、PCB Editor API、そして Schematic API です。なお、各 API には Delphi / Object Pascal のソースコードユニット一式が用意されています。さらに、Altium SDK の C++ 版および C# 版も利用可能です。
Windows 7 上で標準の Altium SDK をインストールした場合、Embarcadero Delphi アプリケーションは SDK の \Examples\System
Windows のフォルダーおよびユーザー権限を適切に変更することもできますが、最も簡単な回避策は、生成された DLL を手動でコピーし、拡張機能プロジェクトの設定ファイル(INS ファイルや RCS ファイルなど)と一緒に Altium Designer の System フォルダーへ配置することです。詳細は、Setting up your Server Project セクション(Getting started: Building a Delphi extension ドキュメント内)を参照してください。
DXP Platform
SDK を使って Schematic ドキュメントを別のファイル形式で保存できますか?
はい、可能です。利用可能なドキュメント形式は、回路図ドキュメントについて Ascii、Orcad、Template、Binary、standard schematic binary、AutoCad DXF、AutoCad DWG です。なお、Template、Binary、および空文字列 "" の 3 つは、同じ Altium Designer の Schematic Design 形式を表します。
コードスニペット:
doc := Client.GetDocumentByPath(ProjectDoc.DM_FullPath); doc.SetModified(TRUE); doc.DoFileSave(documentKind);
ドキュメントを別の形式で保存するには、documentKind
'ASCII' – ASCII format
'ORCAD' – ORCAD format
'TEMPLATE'
'BINARY' – standard binary format
'AUTOCAD DXF' – DXF format
'AUTOCAD DWG' – DWG format
プロジェクトがコンパイル済みかどうか、またそのコンパイル結果が最新かどうかを判定できますか?
多くの処理では、プロジェクトがコンパイルされている必要があります。プロジェクトがコンパイル済みで、その後変更されていないかが分からなければ、データにアクセスする前に毎回プロジェクトを無条件にコンパイルするしかありません。この不要なコンパイルを避ける方法があります。
DM_NeedsCompileIProjectEDPInterfaces
IProjectFunction IProject.DM_NeedsCompile : LongBool;
サーバーモジュールは PluginFactory 関数内でのみ作成できますか(SDK サンプルのように)?
サーバーモジュールは任意の場所で作成できます。たとえば、DLL モジュールのロード時(Initialization 句内)でも可能です。
Altium Designer アプリケーションは、Dynamic Linked Library ファイル(DLL)をロードした直後に PluginFactoryMainPluginFactory
通常、Altium Designer は、そのサーバーモジュールに関連するコマンドを起動する必要が生じたときに、指定されたサーバーモジュールをロードします(PluginFactoryServer EndSystemExtension = True
Server EditorName = ... ... SystemExtension = True End
古いバージョンのプロジェクトを Altium Designer 13.1 に更新できますか?
互換性に関する問題は、DXP Service Pack 2 など Altium Designer 以前のサーバープロジェクトのメインユニットに集中しています。stdcallAddCommand
サーバープロジェクトのメインユニットでは、次の項目を見直す必要があります。
-
procedure をAddCommand procedure に置き換えるRegisterCommand -
コメント:
クラスの集約クラスとしてのTServerModule に対して、CommandLauncher メソッドをAddCommand に置き換えてください。AddCommand メソッドは Altium Designer には存在しません。代わりに、宣言したコマンド(process)を Altium Designer のサーバーテーブルに格納するにはRegisterCommand メソッドを使用してください。RegisterCommand -
をStdcallSafeCall; - に置き換える コメント: safecall キーワードは COM の世界で使用され、EXE から DLL のような境界をまたぐ関数インポートの障害に対して、より安全に保護されます。
-
をPChar メソッドに置き換える。WideString -
コメント:
のTServerModule メソッドは、パラメーターシグネチャがわずかに変更されています。PChars をNewDocumentInstance に置き換えてください。WideStrings
拡張機能から他の process を実行するにはどうすればよいですか?
EDPUtilMessageRouter_SendCommandToModule
ターゲットウィンドウハンドルは、その process を実行する対象ドキュメントオブジェクトのウィンドウハンドルを指定します。サーバーでサポートされるドキュメントが存在しない場合、このパラメーターは Nil
process は Parameters パラメーターを使って結果を返すことができます。たとえば、"Client:RunCommonDialog
Schematic の Zoom Process を呼び出す例:
Procedure ZoomToDoc; Var Parameters : WideString; Begin SetState_Parameter(Parameters, 'Action', 'Document'); MessageRouter_SendCommandToModule('SCH:Zoom', Parameters, MessageRouter_GetState_CurrentEditorWindow); End;
文字列 'Action=Document'parameterSCH:Zoom
PCB の例:
CommandLauncher.LaunchCommand('PCB:Zoom', 'Action=Redraw', Client.CurrentView);
拡張機能プロジェクトに新しい Delphi フォームを追加するにはどうすればよいですか?
既定では、Delphi はアプリケーションのプロジェクトソースユニットに次のコードを含めることで、アプリケーションのメインフォームを自動的にメモリ上に作成します: Application.Create(TForm1,Form1);
これらのプロジェクトは EXE(実行可能)ファイルとしてコンパイルされます。しかし、サーバープロジェクトは DLL ファイルとしてコンパイルされるため、メインフォームは実行時に自動作成されません。フォームは動的に作成する必要があります。ダイアログフォームをサーバープロジェクトに組み込む手順は次のとおりです:
-
Delphi で
File » New » VCL フォームをクリックすると、サーバーライブラリモジュール(プロジェクトファイル内)にフォームが生成され、ライブラリソースの 句にUses 句が追加されます。Form -
新しいフォームに対応するユニットがアクティブになっていることを確認してください。この新しいユニットの
ディレクティブに、必要な Altium Designer API(例:Uses )を追加します。EDPClasses -
次のステップは、実行時にダイアログを作成することです(process が呼び出されたときにダイアログを表示します)。サーバープロジェクトの
ユニットで定義される process 群が開始点となり、各 process の内部から、このサーバープロジェクトを構成する別ユニット内の関数が呼び出されることがあります。フォームを有効化するには、次のコードスニペットを実装する必要があります。commands.pas
commands.pas
Procedure Command_ProcessA(View : IServerDocumentView; Parameters : WideString); Begin MyDialog := TMyDialog.Create(Application); MyDialog.ShowModal; MyDialog.Free; End;
ダイアログのオーナーハンドルを Altium Designer に属させるために Altium Designer のアプリケーションハンドルを取得するには、サーバープロジェクトのメインユニットにある ServerFactoryClient.ApplicationHandleApplication.Handle
PlugInFactory
Function PlugInFactory (AClient : IClient) : IServerModule; Begin Result := TCustomizedServerModule.Create(AClient, 'CustomServer'); Application.Handle := Client.ApplicationHandle; End;
特定のパスを使ってドキュメントを開くにはどうすればよいですか?
IClientOpenDocumentShowDocumentEDPInterfacesIWorkspaceDM_GetDocumentFromPath
コードスニペット:
_Client := Client; If _Client = Nil Then Exit; Kind := Client.GetDocumentKindFromDocumentPath(FileName); ServerDocument := Client.OpenDocument(Kind,FileName); If ServerDocument <> Nil Then Client.ShowDocument(ServerDocument)
コードスニペット:
WorkSpace := GetWorkspace; //IWorkSpace interface If WorkSpace = Nil then Exit; //FullPath is a string containing the full path to the document. Document := WorkSpace.DM_GetDocumentFromPath(FullPath); //IDocument interface Kind := Client.GetDocumentKindFromDocumentPath(FileName); ServerDocument := Client.OpenDocument(Kind,FileName); If ServerDocument <> Nil Then Client.ShowDocument(ServerDocument)
Altium Designer でプログラムからドキュメントを閉じるにはどうすればよいですか?
IClientCloseDocumentIServerDocument
コードスニペット:
_Client := Client; If _Client = Nil Then Exit; //ADocument is of IServerDocument type. _Client.CloseDocument(ADocument);
アクティブな Document を取得するにはどうすればよいですか?
Altium Designer でロード済みプロジェクトのアクティブドキュメントを取得するには、EDPInterfaces IWorkSpaceDM_FocusedDocument
コードスニペット:
WorkSpace := GetWorkspace; //IWorkSpace interface If WorkSpace = Nil then Exit; Document := WorkSpace.DM_FocusedDocument; //IDocument interface
自分のドキュメントをフォーカスされた、またはアクティブなドキュメントにするにはどうすればよいですか?
EDPInterfacesIServerDocumentViewSetFocusIServerDocumentFocus
なお、IServerDocumentIServerDocumentIServerDocumentViewsViewSetFocus
コードスニペット:
WorkSpace := GetWorkspace; //IWorkSpace interface If WorkSpace = Nil then Exit; Document := WorkSpace.DM_FocusedDocument; //Grab the focused IDocument object Document.Focus; // focus this document.
アクティブな Document のタイプ(document kind)を確認するにはどうすればよいですか?
EDPClassesClientcurrentView
コードスニペット 1 – Client インターフェースを使用:
_Client := Client; If _Client = Nil Then Exit; //Check if a schematic document exists or not. CurrentView := _Client.CurrentView; // IServerDocumentView OwnerDocument := CurrentView.OwnerDocument; // IServerDocument If OwnerDocument.Kind = 'SCH' Then ShowMessage('A Schematic document');
または
コードスニペット 2 – Workspace インターフェースを使用:
WorkSpace := GetWorkspace; //IWorkSpace interface If WorkSpace = Nil then Exit; Doc := WorkSpace.DM_FocusedDocument; If Doc.DM_DocumentKind = 'SCH' Then ShowMessage('A Schematic document');
アクティブな Project を取得するにはどうすればよいですか?
まず workspace オブジェクトが必要で、その後 DM_FocusedProjectGetWorkspaceEDPUtil IWorkspaceEDPInterfaces
コードスニペット:
WorkSpace := GetWorkspace; //workspace is a IWorkSpace interface If WorkSpace = Nil then Exit; FocusedProject := WorkSpace.DM_FocusedProject; //FocusedProject = IProject interface
アクティブな Project 内の documents を反復処理するにはどうすればよいですか?
アクティブ / フォーカスされたプロジェクトを取得するには、EDPInterfacesIWorkspaceDM_FocusedProject
コードスニペット:
WorkSpace := GetWorkspace; //IWorkSpace interface If WorkSpace = Nil then Exit; Project := WorkSpace.DM_FocusedProject; //IProject interface For K := 0 To Project.DM_PhysicalDocumentCount – 1 Do Begin Document := Project.DM_PhysicalDocuments(K); S := Document.DM_FullPath; //s is the full filename of the document. End;
プロジェクトの論理ドキュメントを反復処理するにはどうすればよいですか?
プロジェクトの論理ドキュメントを検索するには、EDPInterfacesIProjectDM_LogicalDocuments
コードスニペット:
WorkSpace := GetWorkspace; //IWorkSpace interface If WorkSpace = Nil then Exit; Project := WorkSpace.DM_FocusedProject; //IProject interface For K := 0 To Project.DM_LogicalDocumentCount – 1 Do Begin LogicalDocument := Project.DM_LogicalDocuments(K); //IDocument End;
プロジェクトにドキュメントを追加/削除するにはどうすればよいですか?
Workspace manager 関数:
-
DM_AddSourceDocument -
DM_RemoveSourceDocument
Altium Designer でプロジェクトをコンパイルするにはどうすればよいですか?
プロジェクトをコンパイルするには、IProjectDM_Compile
コードスニペット:
WorkSpace := GetWorkspace; If WorkSpace = Nil then Exit; Project := WorkSpace.DM_FocusedProject; If Project = Nil Then Exit; If Project.DM_NeedsCompile Then Project.DM_Compile;
Output Jobs
OutputJob ドキュメントで出力を設定し、実行するにはどうすればよいですか?
プロジェクトから OutputJobDocumentKindOUTPUTJOB
SDK から OutputJob
-
プロジェクト内の
ファイルを見つけます(論理ドキュメントを反復処理)。OutputJob - このファイルを開いてアクティブにします。
- 使用したい「出力コンテナ」に応じてコマンドを実行します。
Procedure Command_PrintOutputJobPDF(View : IServerDocumentView; Parameters : WideString); Var WorkSpace : IWorkspace; Project : IProject; FileName : String; Process : String; ProjectDoc : IDocument; ServerDoc : IServerDocument; i : Integer; Begin WorkSpace := GetWorkspace; If WorkSpace = Nil then Exit; Project := WorkSpace.DM_FocusedProject; If Project = Nil Then Exit; If Project.DM_NeedsCompile Then Project.DM_Compile; For I := 0 To Project.DM_LogicalDocumentCount – 1 Do Begin ProjectDoc := Project.DM_LogicalDocuments(i); If ProjectDoc <> Nil Then Begin If ProjectDoc.DM_DocumentKind = 'OUTPUTJOB' Then Begin FileName := ProjectDoc.DM_FullPath; ServerDoc := Client.OpenDocument('OUTPUTJOB',FileName); If ServerDoc <> Nil Then Begin Client.ShowDocument(ServerDoc); //Process := 'WorkspaceManager:Print'; //Parameters := 'Action=PrintDocument|ObjectKind=OutputBatch'; Process := 'WorkspaceManager:Print'; Parameters := 'Action=PublishToPDF|DisableDialog=True|ObjectKind=OutputBatch'; //Process := 'WorkspaceManager:Print'; //Parameters := 'Action=PublishMultimedia|DisableDialog=True|ObjectKind=OutputBatch'; //Process := 'WorkspaceManager:GenerateReport'; //Parameters := 'Action=Run|ObjectKind=OutputBatch'; RunCommand(Process, Parameters); End; Exit; End; End; End; End;
PCB
PCB プリミティブを変更する標準的な方法は何ですか?
コード:
procedure UpdateTrackFromObject(aObj: TOutlineObject; aTrack: IPCB_Track); begin PCBServer.PreProcess; //PCBServer.SendMessageToRobots(aTrack.I_ObjectAddress, c_BroadCast, PCBM_BeginModify, c_NoEventData); try aT.X1 := round(aObj.X1); aT.Y1 := round(aObj.Y1); aT.X2 := round(aObj.X2); aT.Y2 := round(aObj.Y2); finally //PCBServer.SendMessageToRobots(aTrack.I_ObjectAddress, c_BroadCast, PCBM_EndModify, c_NoEventData); PCBServer.PostProcess; end; end;
これを行うには、次のコードを使用してください:
Procedure UpdateTrackFromObject(aObj: TOutlineObject; aTrack: IPCB_Track); Var Board : IPCB_Board; _PCBServer : IPCB_ServerInterface; begin _PCBServer := PCBServer; If _PCBServer = Nil Then Exit; Board := _PCBServer.GetCurrentPCBBoard; If Board = Nil Then Exit; _PCBServer.PreProcess; Board.DispatchMessage(aTrack, c_Broadcast, PCBM_BeginModify, c_NoEventData); try aT.X1 := round(aObj.X1); aT.Y1 := round(aObj.Y1); aT.X2 := round(aObj.X2); aT.Y2 := round(aObj.Y2); finally Board.DispatchMessage(aTrack, c_Broadcast, PCBM_EndModify, c_NoEventData); _PCBServer.PostProcess; end; end;
アクティブな PCB ボードを取得するにはどうすればよいですか?
PCB ボードのハンドルを取得するには、PCBServerPCBServerGetCurrentPCBBoard
Var Server : IPCB_ServerInterface; PcbBoard : IPCB_Board; Begin Server := PCBServer; PcbBoard := Server.GetCurrentPCBBoard; ... End;
PCB オブジェクトを反復処理するにはどうすればよいですか?
PCB ドキュメント上の PCB オブジェクトを反復処理するには、まず PCB ドキュメントを取得し、次に初期条件(レイヤー、オブジェクトタイプ、反復方法など)を指定してイテレータを設定し、それ以上見つかるオブジェクトがなくなるまで反復処理を実行する必要があります。
特定の PCB オブジェクトを反復処理するにはどうすればよいですか?
特定の PCB オブジェクトを反復処理するには、オブジェクトイテレータの Object Set フィルターに PCB タイプを設定する必要があります。
コードスニペット:
Var ObjectHandle : IPCB_Primitive; IteratorHandle : IPCB_BoardIterator; Server : IPCB_ServerInterface; Begin Server := PCBServer; PcbBoard := Server.GetCurrentPCBBoard; IteratorHandle := PcbBoard.BoardIterator_Create; IteratorHandle.AddFilter_ObjectSet([eNetObject]); IteratorHandle.AddFilter_LayerSet(AllLayers); IteratorHandle.AddFilter_Method(eProcessAll); ObjectHandle := IteratorHandle.FirstPCBObject; While ObjectHandle <> Nil Do Begin ObjectHandle.Index := 0; ObjectHandle := IteratorHandle.NextPCBObject; End; PcbBoard.BoardIterator_Destroy(IteratorHandle); End;
パッドオブジェクトを検索する別の例です。
コードスニペット:
Iterator := Board.BoardIterator_Create; Iterator.AddFilter_ObjectSet([ePadObject]); Iterator.AddFilter_LayerSet_2(cAllLayers); Iterator.AddFilter_Method(eProcessAll); // search and count pads Pad := Iterator.FirstPCBObject; While (Pad <> Nil) Do Begin PadNumber := PadNumber + 1; Pad := Iterator.NextPCBObject; End; Board.BoardIterator_Destroy(Iterator);
選択されている PCB オブジェクトを取得するにはどうすればよいですか?
PCB 設計オブジェクトの SelectedIPCB_Primitive
PCB オブジェクトを更新するにはどうすればよいですか?
PCB オブジェクトの属性を変更した場合、その PCB オブジェクトを更新するために PCB ボードの DispatchMessageDispatchMessagePCBM_BeginModifyPCBM_EndModifyDispatchMessage
コードスニペット
Board.DispatchMessage(Component, c_Broadcast, PCBM_BeginModify, c_NoEventData); If OriginalHeight <> C Then Begin Component.Height := C; CommandLauncher.LaunchCommand('PCB:Zoom', 'Action=Redraw', 255, Client.CurrentView); End; Board.DispatchMessage(Component, c_Broadcast, PCBM_EndModify, c_NoEventData);
PCB ドキュメントに新しい PCB オブジェクトを追加するにはどうすればよいですか?
PCBServerPCBObjectFactoryPCBObjectFactory
Function PCBObjectFactory(Const AObjectId : EDPTypes_PCB.TObjectId; Const ADimensionKind : TDimensionKind; Const ACreationMode : TObjectCreationMode) : IPCB_Primitive;
パラメータのうち、AObjectIDADimensionKindACreationModeeCreate_Default
アークオブジェクトを作成する例:
コードスニペット:
_PCBServer := PCBServer; If _PCBServer = Nil Then Exit; PCB_Board := _PCBServer.GetCurrentPCBBoard; If PCB_Board = Nil Then Exit; _PCBServer.PreProcess; // Current segment is an arc; create an Arc object. IPrimitive := _PCBServer.PCBObjectFactory(eArcObject,eNoDimension,eCreate_Default); If IPrimitive = Nil Then Exit; Arc := IPCB_Arc(IPrimitive); Arc.XCenter := SegmentI.cx; Arc.YCenter := SegmentI.cy; Arc.Layer := ALayer; Arc.LineWidth := AWidth; Arc.Radius := SegmentI.Radius; Arc.StartAngle := SegmentI.Angle1; Arc.EndAngle := SegmentI.Angle2; PCB_Board.AddPCBObject(Arc); _PCBServer.PostProcess;
Schematic
回路図ドキュメントに新しい Parameter を追加するにはどうすればよいですか?
回路図ドキュメントのパラメータは管理できますが、パラメータを hidden または read-only に設定することはできません。以下は、それらを反復処理して新しいパラメータを追加する方法の例です:
Procedure Command_SCHDocParameters(View : IServerDocumentView; Parameters : WideString); Var _SCHServer : ISch_ServerInterface; RobotManager : ISch_RobotManager; WorkSpace : IWorkspace; Project : IProject; FileName : String; ParamName : String; ParamValue : String; ProjectDoc : IDocument; Sch_Doc : ISch_Document; Sch_Sheet : ISch_Sheet; Iterator : ISch_Iterator; SchParameter : ISch_Parameter; SchParameter1: ISch_Parameter; Container : ISch_BasicContainer; Container1 : ISch_BasicContainer; i : Integer; Begin WorkSpace := GetWorkspace; If WorkSpace = Nil then Exit; _SCHServer := SCHServer; If _SCHServer = Nil Then Exit; RobotManager := _SCHServer.RobotManager; If RobotManager = Nil Then Exit; ProjectDoc := WorkSpace.DM_FocusedDocument; If ProjectDoc <> Nil Then Begin If ProjectDoc.DM_DocumentKind = 'SCH' Then Begin FileName := ProjectDoc.DM_FullPath; Sch_Doc := _SCHServer.GetSchDocumentByPath(FileName); If Sch_Doc <> Nil Then Begin Sch_Sheet := ISch_Sheet(Sch_Doc); // Iterating for existing parameter objects. Iterator := Sch_Sheet.SchIterator_Create; Iterator.SetState_IterationDepth(eIterateFirstLevel); Iterator.AddFilter_ObjectSet([eParameter]); Container := Iterator.FirstSchObject; While Container <> Nil Do Begin SchParameter := ISch_Parameter(Container); ParamName := SchParameter.Name; ParamValue := SchParameter.GetState_Text; Container := Iterator.NextSchObject; End; Sch_Sheet.SchIterator_Destroy(Iterator); // Add a new parameter object and put it on the sheet RobotManager.SendMessage(c_FromSystem, c_BroadCast, SCHM_SystemInvalid, c_NoEventData); Container1 := _SCHServer.SchObjectFactory(eParameter, eCreate_Default); SchParameter1 := ISch_Parameter(Container1); SchParameter1.Name := 'TestParam'; SchParameter1.SetState_Text('TestValue'); Sch_Sheet.AddSchObject(SchParameter1); RobotManager.SendMessage(c_FromSystem, c_BroadCast, SCHM_SystemValid, c_NoEventData); End; End; End; End;
アクティブな回路図シートを取得するにはどうすればよいですか?
回路図シートはプロジェクトの一部なので、シートにアクセスするには Workspace と Schematic Server のハンドルを取得する必要があります。Workspace manager オブジェクトを使用すると、フォーカスされているドキュメントを見つけて、そのドキュメントタイプを確認できます。回路図ドキュメントタイプであることが確認できたら、回路図オブジェクトの追加、削除、更新を進めることができます。
WorkSpace := GetWorkspace; If WorkSpace = Nil then Exit; _SCHServer := SCHServer; If _SCHServer = Nil Then Exit; ProjectDoc := WorkSpace.DM_FocusedDocument; If ProjectDoc <> Nil Then Begin If ProjectDoc.DM_DocumentKind = 'SCH' Then Begin FileName := ProjectDoc.DM_FullPath; Sch_Doc := _SCHServer.GetSchDocumentByPath(FileName); If Sch_Doc <> Nil Then Begin Sch_Sheet := ISch_Sheet(Sch_Doc); //this is the focused sheet End; End; End;
回路図オブジェクトを反復処理するにはどうすればよいですか?
回路図ドキュメント上の回路図オブジェクトを反復処理するには、まず回路図ドキュメントを取得し、次に初期条件(オブジェクトタイプや反復方法など)を指定してイテレータを設定し、それ以上見つかるオブジェクトがなくなるまで反復処理を実行する必要があります。イテレータでは、回路図ドキュメント上の親オブジェクトのみ、または親とその子オブジェクトの両方を対象に検索できる点に注意してください。
特定の回路図オブジェクトを反復処理するにはどうすればよいですか?
回路図シートオブジェクトから呼び出したイテレータオブジェクトを設定し、反復の深さを設定し、反復を開始する前にオブジェクトタイプを指定します。
コードスニペット
// Iterating for existing parameter objects. Iterator := Sch_Sheet.SchIterator_Create; Iterator.SetState_IterationDepth(eIterateFirstLevel); Iterator.AddFilter_ObjectSet([eParameter]); Container := Iterator.FirstSchObject; While Container <> Nil Do Begin SchParameter := ISch_Parameter(Container); ParamName := SchParameter.Name; ParamValue := SchParameter.GetState_Text; Container := Iterator.NextSchObject; End; Sch_Sheet.SchIterator_Destroy(Iterator);
選択されている回路図オブジェクトを取得するにはどうすればよいですか?
回路図設計オブジェクトの SelectionGet SetISch_GraphicalObject
回路図オブジェクト/ドキュメントに対してパラメータを反復処理/更新/追加するにはどうすればよいですか?
コード:
Procedure Command_SCHDocParameters(View : IServerDocumentView; Parameters : WideString); Var _SCHServer : ISch_ServerInterface; RobotManager : ISch_RobotManager; WorkSpace : IWorkspace; Project : IProject; FileName : String; ParamName : String; ParamValue : String; ProjectDoc : IDocument; Sch_Doc : ISch_Document; Sch_Sheet : ISch_Sheet; Iterator : ISch_Iterator; SchParameter : ISch_Parameter; SchParameter1: ISch_Parameter; Container : ISch_BasicContainer; Container1 : ISch_BasicContainer; i : Integer; Begin WorkSpace := GetWorkspace; If WorkSpace = Nil then Exit; _SCHServer := SCHServer; If _SCHServer = Nil Then Exit; RobotManager := _SCHServer.RobotManager; If RobotManager = Nil Then Exit; ProjectDoc := WorkSpace.DM_FocusedDocument; If ProjectDoc <> Nil Then Begin If ProjectDoc.DM_DocumentKind = 'SCH' Then Begin FileName := ProjectDoc.DM_FullPath; Sch_Doc := _SCHServer.GetSchDocumentByPath(FileName); If Sch_Doc <> Nil Then Begin Sch_Sheet := ISch_Sheet(Sch_Doc); // Add a new parameter object and put it on the sheet RobotManager.SendMessage(c_FromSystem, c_BroadCast, SCHM_SystemInvalid, c_NoEventData); Container1 := _SCHServer.SchObjectFactory(eParameter, eCreate_Default); SchParameter1 := ISch_Parameter(Container1); SchParameter1.Name := 'TestParam'; SchParameter1.SetState_Text('TestValue'); Sch_Sheet.AddSchObject(SchParameter1); RobotManager.SendMessage(c_FromSystem, c_BroadCast, SCHM_SystemValid, c_NoEventData); End; End; End; End;
Altium Designer のグラフィカルユーザーインターフェース
既存のメニューにメニュー項目を作成し、実行するコードを割り当てるにはどうすればよいですか?
新しいメニュー項目をターゲットのメニュー(ターゲットはたとえば PCB Editor や Schematic Editor)に追加し、それらに拡張サーバーのプロセスランチャーを割り当てる必要があります。行うべきことは 3 つあります:
-
リソースファイル(拡張子
)を Insertion End ブロック付きで更新する必要があります。RCS -
プロジェクトのインストールファイル(拡張子
)に、ターゲットエディタ名の Updates 句を挿入します(たとえば PCB エディタにはINS という名前があります)。AdvPCB -
ターゲットエディタのインストールファイル(PCB または Schematic エディタのインストールファイル)の
ブロックに、拡張サーバーの名前を挿入します。ResourceDependencies
これを行うには、新しいメニュー項目をエディタのメニュー内のどこに表示するかを示す Target ID と Resource reference ID の値を把握している必要があります。これらの TargetID RefID0RCSAdvPCB.rcs
リソースファイル(拡張子 RCS
自分のメニュー項目を PCB メニューに追加するにはどうすればよいですか?
-
プロジェクトのリソースファイル(拡張子
)を Insertion End ブロック付きで更新する必要があります。RCS -
インストールファイル(拡張子
)の Server End ブロック内に、‘INS ’ という名前で Updates 句を挿入します。AdvPCB -
リソースファイルの ResourceDependencies ブロックに、拡張プロジェクトの名前を挿入します。AdvPCB.ins
プラグインのインストールファイルのスニペット:
Server EditorName = 'AddOn' EditorExePath = 'AddOn.DLL' EditorDescription = 'Demonstratory AddOn module' Version = 'Version 6.3.0.6689' Date = '29-Dec-2012' HelpAboutInfo = 'This software is protected by copyright law and international treaties.' Copyright = 'Copyright © Altium Limited 2012' Updates = 'ADVPCB' End
AdvPCB インストールファイルのスニペット:
Server EditorName = 'PCB' EditorExePath = 'ADVPCB.DLL' EditorDescription = 'Altium Designer PCB Editor' Version = 'Version 10.0.0.28321' Date = '03-May-2013' HelpAboutInfo = 'This software is protected by copyright law and international treaties.' Copyright = 'Copyright c Altium Limited 2013' SupportsDDB = True ResourceDependencies 'AutoPlacer' 'CompMake' 'HSEdit' 'LayerStackupAnalyzer' 'Macro' 'MakeLib' 'PCB3D' 'PCBMaker' 'PCBMiter' 'Placer' 'SignalIntegrity' 'HelpAdvisor' 'OrcadLayoutImporter' 'SavePCADPCB' 'AutoPlacer' 'PinSwapper' 'YourPlugInName' End End
ボタンを作成し、それを自分の拡張機能のコマンド(プロセスランチャー)に割り当てるにはどうすればよいですか?
このようなボタンには画像が必要で、それらのビットマップは 18x18 ピクセルサイズである必要があります。ボタンファイル(拡張子 BMP..\System\Buttons
これらのファイルは、エディタのメニュー項目の横に表示される画像や、ツールバーのボタンに使用されます。
独自のパネルを作成するにはどうすればよいですか?
サーバー内でグローバルパネルビューを追加および管理するには、パネルマネージャオブジェクトを構築し、その対応するオブジェクトインターフェースを定義する必要があります。このオブジェクトがグローバルパネルを管理します。このパネルマネージャオブジェクトはインターフェースとしても公開されるため、Extension を表す TServerModule
このパネルを表す Delphi フォームが必要であり、パネルはパネルマネージャオブジェクト内および TServerModuleTServerPanelViewTServerPanelForm
TServerModule
-
パネルフォーム (
)TServerPanelForm -
パネルビュー (
)TServerPanelView - パネルマネージャ(スタンドアロンクラスと、公開メソッドを持つそのインターフェース表現)。
TServermodule
-
ハンドラHandleNotification -
メソッドCreateServerViews
TServerModule
- パネルマネージャオブジェクトを表す Panel Manager プロパティ
TServerPanelFormHandleNotification
通常、TServerPanelViewClient
グローバルパネルを管理するために必要なメソッドをシステムに公開できるよう、Panel manager ユニット内にはマネージャのインターフェース表現が必要です。インターフェース表現はマネージャクラス内で定義され、そこにはパネルフォームフィールドとインターフェースメソッドが含まれます。パネルマネージャが作成されると、パネルフォームはこのマネージャオブジェクトに関連付けられ、パネルのフォームコントロールを更新できるようになります。
TServerModuleCreateServerViewsTServerModule.AddView()Client.AddServerViewServerModule
インストールファイルは、グローバルパネルを反映するために新しい PanelInfo
PanelInfo Name = 'GraphicMessages' Category = 'Graphic' Bitmap = '' Hotkey = 'M' ButtonVisible = True CanDockVertical = True CanDockHorizontal = True End
SDK フォルダー内の Graphic Viewer のサンプルを参照できます。
自分のパネルを PCB パネルに追加するにはどうすればよいですか?
必要なことは 2 つあります。
- 拡張プロジェクトにグローバルパネルを追加する
-
PCB Editor のインストールファイル(
)にadvpcb.ins End ブロックを追加する。PanelInfo
例として、PCB Editor のインストールファイル(advpcb.ins
PanelInfo Name = 'BoardInSight' Category = '&PCB' Bitmap = '' Hotkey = '' ButtonVisible = True CanDockVertical = True CanDockHorizontal = True End
自分のファイルタイプ用の独自エディターを作成するにはどうすればよいですか?
独自のドキュメントタイプを編集するための独自エディターを作成するには、2 つの作業が必要です。
main.pas ユニットでは、サーバードキュメントクラスとサーバーモジュールクラスを定義および実装します。このユニットではサーバープロセスも定義および実装され、これらのサーバープロセスに対応する interfaces ユニットも定義されてリンクされます。ServerFactoryClient
この main.pasTServerModuleTServerDocument
TServerModuleTGraphicViewerModuleTServerDocumentTGraphicDocument
TServerDocumentmain.pascommands.pas
SDK インストールの \Examples\GraphicViewer\Main.pas
各ドキュメント種別は、この EditorWindowKindEditorWindowKindLoadFiltersSaveFilters
SDK フォルダー内の Graphic Viewer のサンプルを参照できます。

