Jul попробуй вот этот скрипт.
'This script add SignalPins tab. 'It will create reports in Text format. 'For better look, turn off 'Word Wrap' item in the Edit menu of Notepad and use Courier or any other fixed width font.
'Arrays of column name and widths. You can modify them to rename, shrink, or expand columns Const Columns = Array("Поз.", "Вывод", "Цепь") Const Widths = Array( 8, 6, 6, 22)
Sub Main fname = ActiveDocument If fname = "" Then fname = "Untitled" End If report = DefaultFilePath & "\" & "Part Report1.rep" Open report For Output As #1 'Output report header Print #1, "Part Report for "; fname Print #1
StatusBarText = "Generating report..." 'Output table header CurCol = 0 For i = 0 to UBound(Columns) OutCell Columns(i) Next Print #1 'Output table rows For Each part in ActiveDocument.Components CurCol = 0 If GetSignalPins(part).Count = 0 Then GoTo LL For Each aPin In GetSignalPins(part) CurCol = 1 OutCell2 part.Name OutCell1 aPin.Number OutCell3 ObjName(aPin.Net) Print #1 Next aPin Print #1 Print #1 LL: Next part Print #1
StatusBarText = "" Close #1 'Do not forget quotes for file name! Shell "Notepad " & Chr(34) & report & Chr(34), 1 End Sub
'Returns collection of signal pins in the given part Function GetSignalPins(obj As Object, Optional Sorted As Boolean = False) Set GetSignalPins = ActiveDocument.GetObjects(0) For Each aPin In obj.Pins If aPin.Gate Is Nothing And Not aPin.Net Is Nothing Then GetSignalPins.Add aPin End If Next If Sorted Then GetSignalPins.Sort End Function
'Pins are not sorted by default (performance issue), so sort them explicitly in report Function GetSortedPins(obj As Object) Set GetSortedPins = obj.Pins GetSortedPins.Sort End Function
Function ObjName (obj As Object) ObjName = IIf(obj Is Nothing, "", obj) End Function
Dim CurCol As Integer 'Current column index staring from 0
Sub OutCell (txt As String) w = Widths(CurCol) txt = Left(txt, w) Print #1, txt; Space(w - Len(txt)); " | "; CurCol = CurCol + 1 End Sub Sub OutCell1 (txt As String) w = Widths(CurCol) txt = Left(txt, w) Print #1, txt; Space(w - Len(txt)); "= "; CurCol = CurCol + 1 End Sub Sub OutCell2 (txt As String) w = Widths(CurCol) txt = Left(txt, w) Print #1, txt; Space(w - Len(txt)); "( "; CurCol = CurCol + 1 End Sub Sub OutCell3 (txt As String) w = Widths(CurCol) txt = Left(txt, w) Print #1, txt; Space(w - Len(txt)); " ) "; CurCol = CurCol + 1 End Sub
|