Invocation of Interactive BOM from script issue because of text variable expansion fails

Hello @qu1ck

I am invoking the Interactive BOM Plugin from a *.BAT script by calling

%KICADPATH%\python.exe %USERPROFILE%\Documents\KiCad\8.0\3rdparty\plugins\org_openscopeproject_InteractiveHtmlBom\generate_interactive_bom.py --no-browser --dest-dir output %1.kicad_pcb

This works fine and all the options for configuring the BOM can be found here. Really awesome!

But when I am using my custom drawing frame that is referenced by

${KICAD_USER_TEMPLATE_DIR}\myframe.kicad_wks

with
grafik

I get the following error:

Loading main.kicad_pcb
E r r o r   l o a d i n g   d r a w i n g   s h e e t . 2024-11-07 23:20:48,138 INFO Compressing pcb data
2024-11-07 23:20:48,287 INFO Dumping pcb data

KiCad places the template information in *.kicad_pro:

"pcbnew": {
    "last_paths": {
...    },
    "page_layout_descr_file": "${KICAD_USER_TEMPLATE_DIR}\myframe.kicad_wks"
  },

and this text variable doesn’t seem to be expanded.
Is there any other solution than giving the full file name in the page properties dialog?
The problem is that KiCad will automatically fill in the path variable instead of the file name when I select the template file by clicking on the folder symbol:
grafik

Do you get an output? If you do you can ignore this error because ibom does not need the worksheet at all.

Yes, I do get an output, even with other text variables being expanded correctly.

What ruins my day is the msg box that pops up and pauses my *.bat
grafik

That popup comes from pcbnew, not from my code, I can’t disable it.
Are you running your bat file from where it is or from where the pcb file is? Try changing working directory in your bat file to the folder where the pcb file and .pro file are. Maybe that way the variable will be picked up.
Another thing you can try is define an environment variable KICAD_USER_TEMPLATE_DIR in your system or bat file, if I remember correctly kicad will parse env vars unless they are overriden in config. So if it can’t find the config then the env var may work.

What are your KiCad and OS details?
There have been bugs related to variable expansion fixed recently.

Hello @qu1ck,
I am using the latest version of KiCad on Windoze 10pro:

Application: KiCad Footprint Editor x64 on x64

Version: 8.0.6, release build

Libraries:
	wxWidgets 3.2.6
	FreeType 2.13.2
	HarfBuzz 9.0.0
	FontConfig 2.14.2
	libcurl/8.8.0-DEV Schannel zlib/1.3.1

Platform: Windows 10 (build 19045), 64-bit edition, 64 bit, Little endian, wxMSW
OpenGL: Intel, Intel(R) UHD Graphics, 4.6.0 - Build 30.0.101.2079

Build Info:
	Date: Oct 14 2024 01:02:33
	wxWidgets: 3.2.6 (wchar_t,wx containers)
	Boost: 1.85.0
	OCC: 7.8.1
	Curl: 8.8.0-DEV
	ngspice: 43
	Compiler: Visual C++ 1939 without C++ ABI

Build settings:

After spending some time with the extensive user options I ended up with this line for calling iBom in my Windoze batch file for generating wonderful interactive HTML BOM.
I’d like to share it if anyone wants to play along at home:

%KICADPATH%\python.exe %USERPROFILE%\Documents\KiCad\8.0\3rdparty\plugins\org_openscopeproject_InteractiveHtmlBom\generate_interactive_bom.py^
	--include-tracks --include-nets --extra-data-file %INFILE%.kicad_pcb^
	--checkboxes Placed  --sort-order "C,R,L,D,Q,U,J,Y,X,F,SW,A,~,HS,CNN,P,NT,MH"^
	--show-fields Bez,Value,Tol,Dielectr,HSG,BEW,MFG,PN --group-fields Bez,Value^
	--dnp-field kicad_dnp^
	--no-browser --dest-dir output  --name-format %INFILE%-BOM %INFILE%.kicad_pcb

The --extra-data-file is required, otherwise there will be no data in table from non standard variable fields :grimacing:

Many thanks to @qu1ck for providing this great piece of software! :+1:

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.