From 7ecddd10bfa003c40ff7803807eaa1138f19b2d9 Mon Sep 17 00:00:00 2001 From: Lakshay983 <56173382+Lakshay983@users.noreply.github.com> Date: Wed, 3 Jan 2024 21:02:06 -0600 Subject: [PATCH 1/3] Added script --- docsgen.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docsgen.py diff --git a/docsgen.py b/docsgen.py new file mode 100644 index 0000000..2ce25c1 --- /dev/null +++ b/docsgen.py @@ -0,0 +1,35 @@ +import os + + +def exportPDF(): + outputDir = (projectDir + "/"+ projectName [:-10] + "Schematic.pdf") # Sets the directory of the output (overwrites the file or creates it) + schematicDir = (projectDir + "/" + schematicName) # Directory for schematic being used to create the PDF + os.system(f"kicad-cli sch export pdf -o {outputDir} {schematicDir}") + +def exportStep(): + outputDir = (projectDir + "/"+ projectName [:-10] + ".step") + pcbDir = (projectDir + "/" + pcbName) # Directory for the pcb being used for step + os.system(f"kicad-cli pcb export step --force --subst-models -o {outputDir} {pcbDir}") + +def exportPCB(): + outputDir = (projectDir + "/"+ projectName [:-10] + "PCB.svg") + pcbDir = (projectDir + "/" + pcbName) # Directory for the pcb being used for SVG + os.system(f"kicad-cli pcb export svg --page-size-mode 2 --exclude-drawing-sheet --layers Edge.Cuts,F.SilkS,F.Cu,B.SilkS,B.Cu -o {outputDir} {pcbDir}") + +schematicName = ""; +pcbName = "" +projectName = "" +projectDir = os.path.dirname(os.getcwd()) # Gets the parents directory since directory is currently in UTSVT-KiCAD +os.chdir(projectDir) # Changes to parent directory +cliPath = r'C:/Program Files/KiCad/7.0/bin' # Path of the KiCAD-cli binary. Gonna need to change for linux and Mac +for i in os.listdir(): + if (i.endswith(".kicad_sch")): + schematicName = i + elif (i.endswith(".kicad_pcb")): + pcbName = i + elif (i.endswith(".kicad_pro")): + projectName = i +os.chdir(cliPath) +exportPDF(); +exportStep(); +exportPCB() \ No newline at end of file From 902e64f9e48964afd4ca2ac056b5ed7e7b4c9e6a Mon Sep 17 00:00:00 2001 From: Lakshay983 <56173382+Lakshay983@users.noreply.github.com> Date: Wed, 3 Jan 2024 21:14:32 -0600 Subject: [PATCH 2/3] added to do --- docsgen.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docsgen.py b/docsgen.py index 2ce25c1..3cc4c1f 100644 --- a/docsgen.py +++ b/docsgen.py @@ -1,11 +1,12 @@ import os - +#To do: Verify that it works with multiline schematics def exportPDF(): outputDir = (projectDir + "/"+ projectName [:-10] + "Schematic.pdf") # Sets the directory of the output (overwrites the file or creates it) schematicDir = (projectDir + "/" + schematicName) # Directory for schematic being used to create the PDF os.system(f"kicad-cli sch export pdf -o {outputDir} {schematicDir}") +#To do: Make it export relative to board origin def exportStep(): outputDir = (projectDir + "/"+ projectName [:-10] + ".step") pcbDir = (projectDir + "/" + pcbName) # Directory for the pcb being used for step @@ -16,11 +17,12 @@ def exportPCB(): pcbDir = (projectDir + "/" + pcbName) # Directory for the pcb being used for SVG os.system(f"kicad-cli pcb export svg --page-size-mode 2 --exclude-drawing-sheet --layers Edge.Cuts,F.SilkS,F.Cu,B.SilkS,B.Cu -o {outputDir} {pcbDir}") -schematicName = ""; +schematicName = "" pcbName = "" projectName = "" projectDir = os.path.dirname(os.getcwd()) # Gets the parents directory since directory is currently in UTSVT-KiCAD os.chdir(projectDir) # Changes to parent directory +#To do: Change depending on linux or windows cliPath = r'C:/Program Files/KiCad/7.0/bin' # Path of the KiCAD-cli binary. Gonna need to change for linux and Mac for i in os.listdir(): if (i.endswith(".kicad_sch")): From 726f2530b209e71ed82cf51d11841cf2154f09b0 Mon Sep 17 00:00:00 2001 From: Lakshay Gupta Date: Thu, 4 Jan 2024 11:50:06 -0600 Subject: [PATCH 3/3] SVG exports all layers and also output an outline STEP --- docsgen.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docsgen.py b/docsgen.py index 3cc4c1f..82370dc 100644 --- a/docsgen.py +++ b/docsgen.py @@ -12,10 +12,15 @@ def exportStep(): pcbDir = (projectDir + "/" + pcbName) # Directory for the pcb being used for step os.system(f"kicad-cli pcb export step --force --subst-models -o {outputDir} {pcbDir}") + outputDir = (projectDir + "/"+ projectName [:-10] + "Outline.step") + os.system(f"kicad-cli pcb export step --force --board-only -o {outputDir} {pcbDir}") + + def exportPCB(): outputDir = (projectDir + "/"+ projectName [:-10] + "PCB.svg") pcbDir = (projectDir + "/" + pcbName) # Directory for the pcb being used for SVG - os.system(f"kicad-cli pcb export svg --page-size-mode 2 --exclude-drawing-sheet --layers Edge.Cuts,F.SilkS,F.Cu,B.SilkS,B.Cu -o {outputDir} {pcbDir}") + #os.system(f"kicad-cli pcb export svg --page-size-mode 2 --exclude-drawing-sheet --layers Cmts.User,Dwgs.User,Edge.Cuts,F.SilkS,F.Cu,B.SilkS,B.Cu -o {outputDir} {pcbDir}") + os.system(f"kicad-cli pcb export svg --page-size-mode 2 --exclude-drawing-sheet --layers * -o {outputDir} {pcbDir}") schematicName = "" pcbName = ""