Compare commits
No commits in common. "main" and "rm" have entirely different histories.
24
LICENSE
24
LICENSE
@ -1,24 +0,0 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <https://unlicense.org>
|
52
README.md
52
README.md
@ -1,51 +1 @@
|
||||
# FuckJLC
|
||||
|
||||
将其他EDA软件的gerber转换为傻逼立创EDA格式的脚本
|
||||
|
||||
立创EDA狗都不用
|
||||
|
||||
# Usage
|
||||
|
||||
首先查看`config.yaml`,修改工作目录等配置信息
|
||||
|
||||
然后查看`rule.yaml`,选择适合你的规则
|
||||
|
||||
然后运行脚本,在输出目录中查看处理完成的gerber
|
||||
|
||||
最后复制钻孔文件
|
||||
|
||||
``` shell
|
||||
# yum/apt/brew/scoop/winget install python
|
||||
pip install pyyaml
|
||||
python modify.py
|
||||
```
|
||||
|
||||
# 文件结构
|
||||
|
||||
* `modify.py` 脚本主文件
|
||||
* `config.yaml` 通用配置信息
|
||||
* `rule.yaml` 针对不同软件gerber的正则识别规则
|
||||
|
||||
# 提示
|
||||
|
||||
目前仅对有限格式的gerber做适配,其他软件请发Issue并附带目录结构或者自力更生PR
|
||||
|
||||
脚本并未严格测试,仅给各位提供一个绕过检测的思路,保险起见仍建议各位手动进行修改
|
||||
|
||||
由于钻孔文件格式千奇百怪,脚本**不处理钻孔文件**,脚本完成后你需要手动复制钻孔文件
|
||||
|
||||
作者并没有仔细研究嘉立创的判定规则,目前看来凑合能用,就这样吧
|
||||
|
||||
作者不为使用脚本造成的任何后果负责
|
||||
|
||||
欢迎一切 新功能/bug/建议/对线/改错字 Issue/PR
|
||||
|
||||
# 工作原理
|
||||
|
||||
脚本将会将你的gerber重命名为立创EDA的命名格式,并在gerber文件的头部添加立创EDA的注释信息
|
||||
|
||||
除此之外,脚本不会做任何处理
|
||||
|
||||
**低调使用**
|
||||
|
||||
**嘉立创舔狗什么时候死啊**
|
||||
removed
|
36
config.yaml
36
config.yaml
@ -1,36 +0,0 @@
|
||||
# 此处存放文件头 文件名等配置信息
|
||||
|
||||
# 工作目录
|
||||
WorkDir: ../
|
||||
|
||||
# 输出目录,可留空
|
||||
DestDir: ../out
|
||||
|
||||
Header: |-
|
||||
G04 EasyEDA v6.5.23, 2023-02-21 20:00:12*
|
||||
G04 79a7123266304c56a38f2e75c23f1545,85767ff9b60442ae9acdb7a1f8f5a820,10*
|
||||
G04 Gerber Generator version 0.2*
|
||||
|
||||
TextFileName: PCB下单必读.txt
|
||||
TextFileContent: |-
|
||||
如何进行PCB下单
|
||||
|
||||
请查看:
|
||||
https://docs.lceda.cn/cn/PCB/Order-PCB
|
||||
|
||||
FileName:
|
||||
Outline: Gerber_BoardOutlineLayer.GKO
|
||||
Top_Cu: Gerber_TopLayer.GTL
|
||||
Bottom_Cu: Gerber_BottomLayer.GBL
|
||||
InnerLayer1_Cu: Gerber_InnerLayer1.G1
|
||||
InnerLayer2_Cu: Gerber_InnerLayer2.G2
|
||||
InnerLayer3_Cu: Gerber_InnerLayer3.G3
|
||||
InnerLayer4_Cu: Gerber_InnerLayer4.G4
|
||||
Top_SilkScreen: Gerber_TopSilkscreenLayer.GTO
|
||||
Bottom_SilkScreen: Gerber_BottomSilkscreenLayer.GBO
|
||||
Top_SolderMask: Gerber_TopSolderMaskLayer.GTS
|
||||
Bottom_SolderMask: Gerber_BottomSolderMaskLayer.GBS
|
||||
Top_SolderPaste: Gerber_TopPasteMaskLayer.GTP
|
||||
Bottom_SolderPaste: Gerber_BottomPasteMaskLayer.GBP
|
||||
Drill_Pth: Drill_PTH_Through.DRL
|
||||
Drill_Npth: Drill_NPTH_Through.DRL
|
94
modify.py
94
modify.py
@ -1,94 +0,0 @@
|
||||
'''
|
||||
Warn = """\033[0;31;40m
|
||||
=======警告=======
|
||||
此脚本仅包含有限的“自动重命名”功能,它:
|
||||
- 不会对Gerber文件进行解析
|
||||
- 不会验证文件格式是否正确
|
||||
- 不会处理钻孔文件
|
||||
- 极有可能损坏你的文件或引起生产错误
|
||||
- 需要你根据实际情况进行修改
|
||||
如果你不知道自己在干什么,请手动修改文件而不是使用脚本
|
||||
请编辑此脚本以解除警告
|
||||
\033[0m"""
|
||||
print(Warn)
|
||||
raise Exception("READ THE WARNING")
|
||||
'''
|
||||
import yaml
|
||||
import os
|
||||
import re
|
||||
|
||||
fconfig = open("config.yaml", "r", encoding="utf-8")
|
||||
frule = open("rule.yaml", "r", encoding="utf-8")
|
||||
Config = yaml.load(fconfig, Loader=yaml.FullLoader)
|
||||
Rule = yaml.load(frule, Loader=yaml.FullLoader)
|
||||
|
||||
|
||||
def rand_str(size):
|
||||
chars = b"0123456789abcdef"
|
||||
data = bytearray(size)
|
||||
for i in range(size):
|
||||
ri = int.from_bytes(os.urandom(4), "big") % len(chars)
|
||||
ch = chars[ri]
|
||||
data[i] = ch
|
||||
return data.decode("utf-8")
|
||||
|
||||
|
||||
def rand_head_line_2():
|
||||
r1 = rand_str(32)
|
||||
r2 = rand_str(32)
|
||||
return f"G04 {r1},{r2},10*"
|
||||
|
||||
|
||||
# random generate header line 2
|
||||
headers = Config["Header"].split("\n")
|
||||
if len(headers) >= 2:
|
||||
headers[1] = rand_head_line_2()
|
||||
Config["Header"] = "\n".join(headers)
|
||||
|
||||
WorkDir = Config["WorkDir"]
|
||||
DestDir = Config["DestDir"]
|
||||
WorkDirFiles = os.listdir(WorkDir)
|
||||
|
||||
if not DestDir:
|
||||
DestDir = os.path.join(WorkDir, "output")
|
||||
if not os.path.exists(DestDir):
|
||||
os.mkdir(DestDir)
|
||||
|
||||
# 创建PCB下单必读文档
|
||||
with open(os.path.join(DestDir, Config["TextFileName"]), "w") as textFile:
|
||||
textFile.write(Config["TextFileContent"])
|
||||
|
||||
# 检验文件是否齐全/重复匹配
|
||||
for key, value in Rule.items():
|
||||
matchFile = []
|
||||
rePattern = re.compile(pattern=value)
|
||||
|
||||
for fileName in WorkDirFiles:
|
||||
if rePattern.search(fileName):
|
||||
matchFile.append(fileName)
|
||||
|
||||
if len(matchFile) < 1:
|
||||
raise Exception(key + "匹配失败")
|
||||
elif len(matchFile) > 1:
|
||||
raise Exception(key + "重复匹配")
|
||||
else:
|
||||
print(key + " -> " + matchFile[0])
|
||||
|
||||
# 改名和加头操作
|
||||
for key, value in Rule.items():
|
||||
matchFile = ""
|
||||
rePattern = re.compile(pattern=value)
|
||||
|
||||
for fileName in WorkDirFiles:
|
||||
if rePattern.search(fileName):
|
||||
matchFile = fileName
|
||||
|
||||
with open(os.path.join(WorkDir, matchFile), "r") as file:
|
||||
fileData = file.read()
|
||||
with open(os.path.join(DestDir, Config["FileName"][key]), "w") as file:
|
||||
file.write(Config["Header"])
|
||||
file.write(fileData)
|
||||
|
||||
fconfig.close()
|
||||
frule.close()
|
||||
exit()
|
@ -1 +0,0 @@
|
||||
pyyaml
|
67
rule.yaml
67
rule.yaml
@ -1,67 +0,0 @@
|
||||
# 此处存放各种规则,用于识别不同软件导出的gerber
|
||||
# 所有规则均支持正则表达式
|
||||
# 用不到的层必须注释掉
|
||||
|
||||
# -------边框层规则-------
|
||||
# Altium Designer根据你画板时边框所在层选择
|
||||
# KiCad一般是-Edge_Cuts或者Keep Out层
|
||||
|
||||
# KiCad
|
||||
# Outline: -Edge_Cuts
|
||||
|
||||
# 禁止布线层 Keep Out,Protel格式文件扩展名
|
||||
# 适用于Altium Designer
|
||||
# Outline: (\.gko|\.GKO)$
|
||||
|
||||
# 机械1层 Mechanical Layer 1,Protel格式文件扩展名
|
||||
# 适用于KiCad Altium Designer
|
||||
# Outline: (\.gm1|\.GM1)$
|
||||
|
||||
# 机械13层 Mechanical Layer 13,Protel格式文件扩展名
|
||||
# 适用于Altium Designer
|
||||
# Outline: (\.gm13|\.GM13)$
|
||||
|
||||
|
||||
# -------其他层规则-------
|
||||
# 根据自身情况选择,务必核对清楚
|
||||
|
||||
# KiCad
|
||||
# Top_Cu: -F_Cu
|
||||
# Bottom_Cu: -B_Cu
|
||||
# # InnerLayer1_Cu: -In1_Cu
|
||||
# # InnerLayer2_Cu: -In2_Cu
|
||||
# # InnerLayer3_Cu: -In3_Cu
|
||||
# # InnerLayer4_Cu: -In4_Cu
|
||||
# Top_SilkScreen: -F_Silkscreen
|
||||
# Bottom_SilkScreen: -B_Silkscreen
|
||||
# Top_SolderMask: -F_Mask
|
||||
# Bottom_SolderMask: -B_Mask
|
||||
# Top_SolderPaste: -F_Paste
|
||||
# Bottom_SolderPaste: -B_Paste
|
||||
|
||||
# Protel格式文件扩展名
|
||||
# 适用于 KiCad Altium Designer
|
||||
# Top_Cu: (\.gtl|\.GTL)$
|
||||
# Bottom_Cu: (\.gbl|\.GBL)$
|
||||
# # InnerLayer1_Cu: (\.g1|\.G1)$ # 请注意内层后缀名是g1/g2还是g2/g3
|
||||
# # InnerLayer2_Cu: (\.g2|\.G2)$
|
||||
# # InnerLayer3_Cu: (\.g3|\.G3)$
|
||||
# # InnerLayer4_Cu: (\.g4|\.G4)$
|
||||
# Top_SilkScreen: (\.gto|\.GTO)$
|
||||
# Bottom_SilkScreen: (\.gbo|\.GBO)$
|
||||
# Top_SolderMask: (\.gts|\.GTS)$
|
||||
# Bottom_SolderMask: (\.gbs|\.GBS)$
|
||||
# Top_SolderPaste: (\.gtp|\.GTP)$
|
||||
# Bottom_SolderPaste: (\.gbp|\.GBP)$
|
||||
|
||||
# 奇怪格式,别管它
|
||||
# Top_Cu: TOP
|
||||
# Bottom_Cu: BOTTOM
|
||||
# InnerLayer1_Cu: MID1_L2
|
||||
# InnerLayer2_Cu: MID2_L3
|
||||
# Top_SilkScreen: SST
|
||||
# Bottom_SilkScreen: SSB
|
||||
# Top_SolderMask: SMT
|
||||
# Bottom_SolderMask: SMB
|
||||
# Top_SolderPaste: SPT
|
||||
# Bottom_SolderPaste: SPB
|
Loading…
x
Reference in New Issue
Block a user