⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 part_list_in_center.bas

📁 PADS Layout把非中心对称封装的元件坐标导出所修改的Basic Scr
💻 BAS
字号:
' Sample 17: Excel Part List Report.BAS
' 
' This sample demonstrates how to generate PADS Layout reports in Excel.
'
' For more details, please refer to the PADS Layout Basic Editor Help File.
'
	' Public centerX As Integer
	' Public centerY As Integer
	' Public cout As Integer
Sub Main
	' Open temporarly text file
	Randomize
	filename = DefaultFilePath & "\tmp"  & CInt(Rnd()*10000) & ".xls"
	Open filename For Output As #1



	' Output Headers
	Print #1, "PartType";	Space(32); 
	Print #1, "RefDes";		Space(24); 
	Print #1, "PartDecal";	Space(32); 
	Print #1, "Pins";		Space(6); 
	Print #1, "Layer";		Space(26); 
	Print #1, "Orient.";	Space(24); 
	Print #1, "X";			Space(30); 
	Print #1, "Y";			Space(29); 
	Print #1, "SMD";		Space(7); 
	Print #1, "Glued";		Space(0)
	
	' Lock server to speed up process
	LockServer

	' Go through each component in the design and output values
	For Each nextComp In ActiveDocument.Components

	    Dim centerX  As Single
	    Dim centerY  As Single
	    Dim cout  As Integer
	    centerX = 0.0
	    centerY = 0.0
	    cout = 0
	    	
		Print #1, nextComp.PartType;	Space$(40-Len(nextComp.PartType)); 
		Print #1, nextComp.Name;		Space$(30-Len(nextComp.Name)); 
		Print #1, nextComp.Decal;		Space$(40-Len(nextComp.Decal)); 
		Print #1, nextComp.Pins.Count;	Space$(10-Len(nextComp.Pins.Count)); 
		Print #1, ActiveDocument.LayerName(nextComp.layer);	Space$(30-Len(ActiveDocument.LayerName(nextComp.layer))); 
		Print #1, nextComp.Orientation;	Space$(30-Len(nextComp.Orientation)); 
		
		' Set compU1 = ActiveDocument.Components(nextComp) 
		For Each nextCompPin In nextComp.Pins
		' If nextComp.Name =  Then
		centerX = centerX+nextCompPin.PositionX 
		centerY = centerY+nextCompPin.PositionY 
		' cout = cout+1
		' End If
		Next nextCompPin
		centerPositionX = Format$(centerX/(nextComp.Pins.Count), "#.00")
		centerPositionY = Format$(centerY/(nextComp.Pins.Count), "#.00")
		
		Print #1, centerPositionX;     	Space$(30-Len(nextComp.PositionX)); 
		Print #1, centerPositionY;     	Space$(30-Len(nextComp.PositionY)); 
		Print #1, nextComp.IsSMD;		Space$(10-Len(nextComp.IsSMD)); 
		Print #1, nextComp.Glued;		Space$(10-Len(nextComp.Glued))
	Next nextComp

	' Unlock the server
	UnlockServer

	' Close the text file
	Close #1
	
	' 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.Range("A1").Select
	Set excelApp = Nothing
	End

noExcel:
	' Display the text file
	Shell "Notepad " & filename, 3

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -