markh-de / KiVar

PCB Assembly Variants for KiCad
MIT License
29 stars 0 forks source link

KiVar v0.2.0 CLI - Error: Assignment 'PCB_VAR1' failed: Format error: Wrong number of '=' separators. #75

Closed rob-bits closed 1 month ago

rob-bits commented 1 month ago

I have successfully installed and using KiVar v0.2.0 plugin since May. Now I am trying to create a python script that changes variant from command line but I got issues. If I list the available variants I get this:

python C:\Users\Lenovo\OneDrive\Documents\KiCad\8.0\3rdparty\Python311\site-packages\kivar\kivar_cli.py list --selection D:\Temp\test-project\test.kicad_pcb DeviceVariant: PCB_VAR1 PCB_VAR2 PCB_VAR3 [PCB_VAR4]

Now when I want to change variant from CLI: python C:\Users\Lenovo\OneDrive\Documents\KiCad\8.0\3rdparty\Python311\site-packages\kivar\kivar_cli.py set --assign PCB_VAR1 --verbose D:\Temp\test-project\test.kicad_pcb I got the following error: Error: Assignment 'PCB_VAR1' failed: Format error: Wrong number of '=' separators.

It is strange, because manually, with KiVar plugin, I can change variants easily. The steps that I made:

  1. in PCB view, I open KiVar plugin and change the variant
  2. save pcb design
  3. update schematic from PCB

And all the neccessary fields are updated, ready to export schematic, bom ...etc.

What I am missing with CLI?


Update 1 I migth use wrongly the CLI command, in KiVar window, I have a propery "DeviceVariant" and a list for that. And I pick one element from the list to select a device variant. If I select one I see this: image

(some text are deleted on purpose from this screenshot. It contains "sensitive" data)

Anyway, using this in the command: --assign 'DeviceVariant=PCB_VAR1' I still got the same error: Error: Assignment ''DeviceVariant=PCB_VAR1'' failed: Format error: Wrong number of '=' separators. No changes.


Update 2 The character ' is not needed in the assign option. So it work if I use: --assign DeviceVariant=PCB_VAR1

So the "tutorial" should be updated according to this.

markh-de commented 1 month ago

Anyway, using this in the command: --assign 'DeviceVariant=PCB_VAR1' I still got the same error: Error: Assignment ''DeviceVariant=PCB_VAR1'' failed: Format error: Wrong number of '=' separators.

Well, I guess you are not running the command from an interactive shell interpreter then. Because this is what the documentation (really just an example) does. The shell interpreter will remove the single-quote characters and keep the quoted part together as one argument. That is why they were used in the example. If you run such commands from a different environment you need to take care of such issues in an appropriate way.

And yes, you need to tell KiVar which aspect is to be modified, because it allows you to have several of them. So it is not sufficient to only pass the choice identifier without aspect context.

Also, I see you are using a development version of KiVar. I strongly recommend to use the latest release 0.3.0. And watch out for version 0.4.0, which will be released soon.

Thanks for sharing your thoughts.