找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 8612|回复: 9
收起左侧

针对PADS Layout把非中心对称封装的元件坐标导出所修改的Basic Script

[复制链接]
ID:90228 发表于 2015-9-16 01:49 | 显示全部楼层 |阅读模式
有时候,做元件封装的时候,做得不是按中心设置为原点(不提倡这种做法),所以制成之后导出来的坐标图和直接提供给贴片厂的要求相差比较大。比如,以元件的某一个pin 脚作为元件的原点,明显就有问题,直接修改封装的话,PCB又的重新调整。

所以想到一个方法:把每个元件所有的管脚的X坐标和Y坐标分别求平均值,
就为元件的中心。


对于大部分元件应该都是完全正确的。

但也有小部分可能稍微有点偏差,比如三极管、管脚间距不完全相等的继电器,当然这部分是很少很少的部分,而且也偏差不大。

贴片厂贴片都会检查一下,特别是不规则的封装,
也无法认定中心应该设置在哪。

不要偏差太大,即可以稍微调整。


把以下代码另存为*.bas文件,然后在PADS Layout中导入。

导入方法:tools——)Basic Script——)Basic Script——)Load file,把保存的.bas文件导入即可。

然后点击run,方法和运行原来就有的我文件一样。

如果 不会操作的 下载 !





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));

For Each nextCompPin In nextComp.Pins
centerX = centerX+nextCompPin.PositionX
centerY = centerY+nextCompPin.PositionY
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


part_list_in_center.rar

1.12 KB, 下载次数: 32, 下载积分: 黑币 -5

回复

使用道具 举报

ID:332724 发表于 2018-5-18 09:18 | 显示全部楼层
谢谢
回复

使用道具 举报

ID:354148 发表于 2018-6-19 14:26 | 显示全部楼层
此算法可能有问题,比如SOT23封装
回复

使用道具 举报

ID:360421 发表于 2018-6-27 17:04 | 显示全部楼层
666,厉害,我们只能做伸手党了,谢谢
回复

使用道具 举报

ID:360421 发表于 2018-6-27 17:05 | 显示全部楼层
非常谢谢
回复

使用道具 举报

ID:135713 发表于 2018-6-28 18:46 来自手机 | 显示全部楼层
支持分享
回复

使用道具 举报

ID:384710 发表于 2018-8-9 17:23 | 显示全部楼层
正在学习PADS ...谢谢
回复

使用道具 举报

ID:360421 发表于 2018-8-25 11:06 | 显示全部楼层
谢谢了
回复

使用道具 举报

ID:809368 发表于 2020-7-29 20:18 | 显示全部楼层
谢谢,对我很有用,非常感谢!
回复

使用道具 举报

ID:250544 发表于 2020-8-2 17:25 | 显示全部楼层
怎么学习的脚本编程,推荐一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表