PCB設(shè)計(jì)完成后,如果我們要統(tǒng)計(jì)過(guò)孔數(shù)量,查看過(guò)孔信息怎么弄呢?可以利用腳本的方法,把PCB鉆孔的信息打印出來(lái)。
首先,打開(kāi)PCB腳本編輯器,編寫以下代碼。
參考代碼如下:
Dim DrillCount As Long
Sub Main
Randomize
filename = DefaultFilePath & " mp" & CInt(Rnd()*10000) & ".txt"
Open filename For Output As #1
Print #1, "Type";Space(9);
Print #1, "Name";Space(26);
Print #1, "Net";Space(28);
Print #1, "Drill";Space(25);
Print #1, "Plated";Space(2);
Print #1, "X";Space(29);
Print #1, "Y";Space(0)
DrillCount = 0
' Lock server to speed up process
LockServer
' Go through each via in the design and output values
For Each nextVia In ActiveDocument.Vias
' Output Via Type Property
a = "Via"
Print #1, a; Space$(13-Len(a));
' Output Via Name Property
a = nextVia.Type
Print #1, a; Space$(30-Len(a));
' Output Via Attached Net Property
Set nnet = nextVia.Net
If (nnet Is Nothing) Then a = "N/A" Else a = nnet.Name
Print #1, a; Space$(30-Len(a));
' Output Via Drill Size Property
a = nextVia.DrillSize
Print #1, a; Space$(30-Len(a));
' Output Via Plated Property
a = nextVia.Plated
Print #1, a; Space$(8-Len(a));
' Output Via PositionX Property
a = Format$(nextVia.PositionX, "#.00")
Print #1, a; Space$(30-Len(a));
' Output Via PositionY Property
a = Format$(nextVia.PositionY, "#.00")
Print #1, a
DrillCount = DrillCount + 1
Next nextVia
' Unlock the server
UnlockServer
' Close the text file
Close #1
If DrillCount = 0 Then
MsgBox "The design has no drills"
Exit Sub
End If
' Start Excel and loads the text file
On Error GoTo noExcel
Dim excelApp As Object
Set excelApp = CreateObject("Excel.Application")
On Error GoTo 0
excelApp.Visible = True
excelApp.Workbooks.OpenText FileName:= filename
excelApp.Rows("1:1").Select
With excelApp.Selection
.Font.Bold = True
.Font.Italic = True
End With
excelApp.Cells.Select
excelApp.Selection.Sort Key1:=excelApp.ActiveSheet.Columns("D"), Order1:=1, Header:=0
excelApp.Selection.Subtotal GroupBy:=4, Function:=-4112, TotalList:=Array(5), Replace:=True
excelApp.ActiveSheet.Outline.ShowLevels RowLevels:=2
excelApp.Range("A1").Select
Set excelApp = Nothing
End
noExcel:
' Display the text file
Shell "Notepad " & filename, 3
End Sub
然后,運(yùn)行腳本,PCB的過(guò)孔信息就被打印出來(lái)了。
由上圖可以知道,過(guò)孔的類型,大小,坐標(biāo)都打印出來(lái),數(shù)量也統(tǒng)計(jì)出來(lái)了。
最后,保存腳本,方便以后調(diào)用。
感興趣的朋友,可以敲寫以上代碼調(diào)試使用,也可以到群里下載腳本,直接使用。
編輯:hfy
-
PCB設(shè)計(jì)
+關(guān)注
關(guān)注
394文章
4668瀏覽量
85135
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論