WIP: pre-panel script to parse and impl panel info
This commit is contained in:
@@ -33,8 +33,8 @@ dest["board"]["design_settings"]["rule_severities"]["hole_near_hole"] = "ignore"
|
||||
dest["board"]["design_settings"]["rule_severities"]["silk_overlap"] = "ignore"
|
||||
dest["board"]["design_settings"]["rule_severities"]["silk_over_copper"] = "ignore"
|
||||
dest["board"]["design_settings"]["rule_severities"]["drill_out_of_range"] = "ignore"
|
||||
# This one is just until kibot image is updated to 7.0.5
|
||||
dest["board"]["design_settings"]["rule_severities"]["copper_sliver"] = "ignore"
|
||||
# # This one is just until kibot image is updated to 7.0.5
|
||||
# dest["board"]["design_settings"]["rule_severities"]["copper_sliver"] = "ignore"
|
||||
dest["net_settings"]["classes"] = src["net_settings"]["classes"]
|
||||
dest["net_settings"]["netclass_patterns"] = src["net_settings"]["netclass_patterns"]
|
||||
|
||||
|
||||
98
.scripts/pre_panel.py
Normal file
98
.scripts/pre_panel.py
Normal file
@@ -0,0 +1,98 @@
|
||||
import json
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
proj_file = sys.argv[1]
|
||||
pcb_file = sys.argv[2]
|
||||
panel_file = sys.argv[3]
|
||||
|
||||
def num_to_mm(input: str) -> float:
|
||||
input = input.lower()
|
||||
# Panic, should all be in mm for sanity's sake
|
||||
if "mm" not in input:
|
||||
print(input, "not in mm")
|
||||
exit(1)
|
||||
return float(input.replace("mm", ""))
|
||||
|
||||
|
||||
class Text:
|
||||
def __init__(self, text: str, anchor: str, offset: (float, float), rot: float, size: (float, float, float), just: (str, str)):
|
||||
self.text = text
|
||||
self.anchor = anchor
|
||||
self.hoff = offset[0]
|
||||
self.voff = offset[1]
|
||||
self.rot = str(rot)+"deg"
|
||||
self.width = size[0]
|
||||
self.height = size[1]
|
||||
self.thickness = size[2]
|
||||
self.hjust = just[0]
|
||||
self.vjust = just[1]
|
||||
|
||||
# def to_json(self) ->
|
||||
|
||||
|
||||
class Frame:
|
||||
def __init__(self, ftype: str, width: str, spacing: str):
|
||||
self.ftype = ftype.lower()
|
||||
self.width = num_to_mm(width)
|
||||
self.spacing = num_to_mm(spacing)
|
||||
|
||||
class Panel:
|
||||
def __init__(self, spacing: str, frame: Frame):
|
||||
self.spacing = num_to_mm(spacing)
|
||||
self.frame = frame
|
||||
|
||||
self.text = "{boardTitle}-{boardRevision}"
|
||||
if "frame" in self.frame.ftype or "tb" in self.frame.ftype:
|
||||
if "frame" in self.frame.ftype:
|
||||
else:
|
||||
self.text2 = None
|
||||
self.text3 = None
|
||||
|
||||
print("Starting post_panel script")
|
||||
|
||||
dest_folder = '/'.join(proj_file.split('/')[:-1])
|
||||
dest_name = proj_file.split('/')[-1].removesuffix(".kicad_pro")
|
||||
|
||||
src_name = pcb_file.removesuffix(".kicad_pcb")
|
||||
src_proj = src_name + ".kicad_pro"
|
||||
|
||||
try:
|
||||
shutil.copy(src_name + ".kicad_dru", dest_folder + "/" + dest_name + ".kicad_dru")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
json_file = open(panel_file)
|
||||
json_str = json_file.read()
|
||||
panel_json = json.loads(json_str)
|
||||
|
||||
frame = Frame(panel_json["framing"]["type"], panel_json["framing"]["width"], panel_json["framing"]["spacing"])
|
||||
panel = Panel(panel_json["layout"]["space"], frame)
|
||||
|
||||
|
||||
|
||||
json_file = open(src_proj)
|
||||
json_str = json_file.read()
|
||||
src = json.loads(json_str)
|
||||
|
||||
json_file = open(proj_file)
|
||||
json_str = json_file.read()
|
||||
dest = json.loads(json_str)
|
||||
|
||||
# dest["board"]["design_settings"]["rule_severities"]["duplicate_footprints"] = "ignore"
|
||||
# dest["board"]["design_settings"]["rule_severities"]["extra_footprint"] = "ignore"
|
||||
# dest["board"]["design_settings"]["rule_severities"]["lib_footprint_issues"] = "ignore"
|
||||
# dest["board"]["design_settings"]["rule_severities"]["lib_footprint_mismatch"] = "ignore"
|
||||
# dest["board"]["design_settings"]["rule_severities"]["hole_near_hole"] = "ignore"
|
||||
# dest["board"]["design_settings"]["rule_severities"]["silk_overlap"] = "ignore"
|
||||
# dest["board"]["design_settings"]["rule_severities"]["silk_over_copper"] = "ignore"
|
||||
# dest["board"]["design_settings"]["rule_severities"]["drill_out_of_range"] = "ignore"
|
||||
# # # This one is just until kibot image is updated to 7.0.5
|
||||
# # dest["board"]["design_settings"]["rule_severities"]["copper_sliver"] = "ignore"
|
||||
# dest["net_settings"]["classes"] = src["net_settings"]["classes"]
|
||||
# dest["net_settings"]["netclass_patterns"] = src["net_settings"]["netclass_patterns"]
|
||||
|
||||
with open(proj_file, mode="w") as json_file:
|
||||
json.dump(dest, json_file, indent=2)
|
||||
|
||||
print("Finished post_panel script")
|
||||
Reference in New Issue
Block a user