Thank you. I was thinking of something like that as an option.
So far Iāve got this āworkaroundā: a folder with structure:
- notes (folder)
--> kicad_src (folder)
--> images (folder)
--> docs (folder)
--> convert_kicad_to_svg.ps1 (PowerShell script)
The content of PowerShell script is:
$SourceFolder = Join-Path -Path "$PSScriptRoot" -ChildPath "kicad_src"
$ExportFolder = Join-Path -Path "$PSScriptRoot" -ChildPath "svg_export"
Write-Host "$SourceFolder"
Write-Host "$ExportFolder"
Set-Alias -Name kicad-cli -Value "C:\Program Files\KiCad\8.0\bin\kicad-cli.exe"
Set-Alias -Name inkscape "C:\Program Files\Inkscape\bin\inkscape.exe"
ForEach ($schematics_file in Get-ChildItem -Path "$SourceFolder" -Recurse -Force -Include *.kicad_sch){
kicad-cli sch export svg "$schematics_file" --output "$ExportFolder" -e -n
$OutputFile = Join-Path -Path "$ExportFolder" -ChildPath (($schematics_file).BaseName + '.svg')
inkscape -T -D -o "$OutputFile" "$OutputFile"
}
There is extra involvement of InkScape since KiCad exports the whole page (even when there is the key of no frame), so wanted to crop images.
These images will be later indeed referenced in the Word, etc. and supposed to be auto-updated when document is re-opened.
So far, unclear is inkscape export with margins. It might have been working with command:
# This was supposed to add margin of 2 units of the document (mm or other)
inkscape --export-plain-svg --export-margin=2 --export-area-drawing --export-overwrite "$OutputFile"
but it doesnāt work as of now.
UPD: After some thinking. made some rearrangements:
-> root (Folder)
--> convert_kicad_to_svg.ps1 (PowerShell script)
--> topics (Folder)
---> Topic_1 (folder()
----> document (whaever_extension is needed)
----> kicad_src (folder with Kicad Schematics)
----> kicad_img (folder with Kicad exports)
The content for script is:
$SourceFolderName = "kicad_src"
$ExportFolderName = "kicad_img"
Set-Alias -Name kicad-cli -Value "C:\Program Files\KiCad\8.0\bin\kicad-cli.exe"
Set-Alias -Name inkscape "C:\Program Files\Inkscape\bin\inkscape.exe"
ForEach ($kicad_src_folder in Get-ChildItem -Path "$PSScriptRoot" -Recurse -Force -Directory -Filter "$SourceFolderName") {
$kicad_export_folder = Join-Path -Path $(Split-Path $kicad_src_folder.FullName -parent) -ChildPath $ExportFolderName
If(!(test-path -PathType container $kicad_export_folder)) {
New-Item -ItemType Directory -Path $kicad_export_folder
}
ForEach ($schematics_file in Get-ChildItem -Path $kicad_src_folder.FullName -Recurse -Force -Include *.kicad_sch) {
$OutputFile = Join-Path -Path "$kicad_export_folder" -ChildPath (($schematics_file).BaseName + '.svg')
kicad-cli sch export svg "$schematics_file" --output "$kicad_export_folder" -e -n
inkscape --export-plain-svg --export-margin=2 --export-area-drawing --export-overwrite "$OutputFile"
}
}
This is not exactly what I originally wanted, but is already āauto-updatedā if any changes were incorporated to the schematics.