Skip to content

Commit f871d3b

Browse files
committed
Add new option -p to set a file prefix
1 parent 0ad34cc commit f871d3b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

render-pcb.sh

+14-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ help() {
1010
echo "f Path to .kicad_pcb file"
1111
echo "b Image background. Options: transparent, opaque. Default: transparent for PNG, opaque for JPEG"
1212
echo "o Directory where the images and optinally the animation should be written to."
13+
echo "p Set a prefix for the images diffrent from project name"
1314
echo "a Render animation and select animation output format (mp4 or gif)."
1415
echo "z Camera zoom default 1"
1516
echo "v Print protgram version"
@@ -28,11 +29,12 @@ extract_output_path() {
2829

2930
background="transparent"
3031

31-
while getopts :f:o:a:b:z:hv option
32+
while getopts :f:o:p:a:b:z:hv option
3233
do
3334
case "${option}" in
3435
f) kicad_pcb=${OPTARG};;
3536
o) output_path=${OPTARG};;
37+
p) filename_prefix=${OPTARG};;
3638
a) animation=${OPTARG};;
3739
b) background=${OPTARG};;
3840
z) zoom=${OPTARG};;
@@ -50,7 +52,8 @@ fi
5052

5153
if [[ -z "$output_path" ]]; then
5254
path=$(extract_output_path "$2")
53-
name=$(extract_project_name "$2")
55+
extracted_project_name=$(extract_project_name "$2")
56+
name="${filename_prefix:-$extracted_project_name}"
5457
echo "name: $name"
5558
echo "path: $path"
5659
output_path="$path"
@@ -59,9 +62,15 @@ if [[ -z "$output_path" ]]; then
5962
echo "output_top: $output_top"
6063
echo "output_bottom: $output_bottom"
6164
else
62-
output_top="$output_path/top.png"
63-
output_bottom="$output_path/bottom.png"
64-
output_animation="$output_path"
65+
if [[ -n "$filename_prefix" ]]; then
66+
output_top="$output_path/${filename_prefix}_top.png"
67+
output_bottom="$output_path/${filename_prefix}_bottom.png"
68+
output_animation="$output_path"
69+
else
70+
output_top="$output_path/top.png"
71+
output_bottom="$output_path/bottom.png"
72+
output_animation="$output_path"
73+
fi
6574
fi
6675

6776

0 commit comments

Comments
 (0)