Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python script for board documentation #24

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docsgen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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
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 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 = ""
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")):
schematicName = i
elif (i.endswith(".kicad_pcb")):
pcbName = i
elif (i.endswith(".kicad_pro")):
projectName = i
os.chdir(cliPath)
exportPDF();
exportStep();
exportPCB()