我正在编写一个Delphi Altium脚本来删除PCB库内TopOverLay中的所有轨迹。
但是,当运行脚本时,什么也没有发生(曲目不会被删除)。
我也不知道原因。你能帮帮我吗?
下面是我的代码:
procedure RemoveTrackObject;
Var
MyComponent : IPCB_LibComponent;
MyTrack : IPCB_Track;
Iterator : IPCB_GroupIterator;
DeleteList : TInterfaceList;
TrackTemp : IPCB_Track;
i : Integer;
begin
MyComponent := PCBServer.GetCurrentPCBLibrary.CurrentComponent;
//////////////////////////////////////////////////////////////////////
Iterator := MyComponent.GroupIterator_Create;
Iterator.AddFilter_ObjectSet(Mkset(eTrackObject));
Iterator.AddFilter_LayerSet(Mkset(eTopOverLay));
DeleteList := TInterfaceList.Create;
try
MyTrack := Iterator.FirstPCBObject;
While MyTrack <> nil do
begin
DeleteList.Add(MyTrack);
MyTrack := Iterator.NextPCBObject;
end;
finally
MyComponent.GroupIterator_Destroy(Iterator);
end;
try
PCBServer.PreProcess;
for i := 0 to DeleteList.Count - 1 do
begin
TrackTemp := DeleteList.Items[i];
MyComponent.RemovePCBObject(TrackTemp);
end;
finally
PCBServer.PostProcess;
DeleteList.Free;
end;
Client.SendMessage('PCB:Zoom', 'Action=Redraw' , 255, Client.CurrentView);
end;发布于 2020-10-10 03:15:50
Altium dephiscript API InterfaceList中的AFAIU有特殊的用途:保存非印刷电路板对象&传递给外部dll函数&让接收的fn销毁列表。在这里你并不真的需要。
PcbLib确实有一些奇怪的行为,比如从选定/聚焦的footprint中删除内容等。
我认为问题是由于Pcb Editor不允许从当前聚焦的元件/封装外形中删除对象造成的。围绕这个问题的历史表明,解决方案涉及将焦点从所需的组件上移开。
当列表中仍包含对象引用时,您无法完成删除过程。
使用While循环,在RemovePCBObject()之后,从列表中删除对象引用(删除列表项)。然后,当While循环终止时,List中的项为零。
可能有助于刷新或使用其中一些fn调用的外观:
CurrentLib.Board.GraphicallyInvalidate;
CurrentLib.Navigate_FirstComponent;
CurrentLib.Board.ViewManager_FullUpdate;
CurrentLib.Board.GraphicalView_ZoomRedraw;
CurrentLib.RefreshView;https://stackoverflow.com/questions/64068633
复制相似问题