easyeda2kicad.py
easyeda2kicad.py copied to clipboard
Issue Adding new part to sym library
Running latest v0.8 version
If I use this command: easyeda2kicad --full --lcsc_id=C1850276 --output "D:\Documents\Git Repositories\KICAD\LCSC Components\LCSC_lib"
followed by this command to add another part:
easyeda2kicad --full --lcsc_id=C3662799 --output "D:\Documents\Git Repositories\KICAD\LCSC Components\LCSC_lib"
The generated file named "LCSC_lib.kicad_sym" is formatted incorrectly
To fix I have to manually go into file and remove ")" before the newly inserted sysmbol reference
I am also experiencing this quite consistently. I BELIEVE the issue began for me when I upgraded from KiCad v7 to v8, though I'm not sure if the formatting of the symbol library file has changed in any meaningful way.
I get this very often as well. An example part that gave this error was C496551. It doesn't happen every time so I wonder if it may be related to specific parts. @OnlineDynamic's fix worked for me as well. I hadn't worked out what exactly was wrong with the files that were being made and I was up to easyeda2kicad_8.kicad_sym on this project alone lol. Thanks so much!
easyeda2kicad8.txt Figured I should put this in as an example, this is the working file after I removed the ) from before the C496551 part but hopefully it allows replication.
I could not reproduce this issue with the part C496551, mine was added successfully:
and the file looks good as well
easyeda2kicad.txt
I updated helper.py's add_component_in_symbol_lib_file function to the following and no longer have issues with the extra ")"
I hope this helps someone else keep their sanity, because I lost mine for a moment going into the easyeda2kicad.kicad_sym file every time I added a symbol via terminal
def add_component_in_symbol_lib_file(
lib_path: str, component_content: str, kicad_version: KicadVersion
) -> None:
if kicad_version == KicadVersion.v5:
with open(file=lib_path, mode="a+", encoding="utf-8") as lib_file:
lib_file.write(component_content)
elif kicad_version == KicadVersion.v6:
with open(file=lib_path, mode="rb+") as lib_file:
lib_file.seek(-1, 2) # Changed from -2 to -1
lib_file.truncate()
lib_file.write(component_content.encode(encoding="utf-8"))
lib_file.write("\n)".encode(encoding="utf-8"))
with open(file=lib_path, encoding="utf-8") as lib_file:
new_lib_data = lib_file.read()
with open(file=lib_path, mode="w", encoding="utf-8") as lib_file:
lib_file.write(
new_lib_data.replace(
"(generator kicad_symbol_editor)",
"(generator https://github.com/uPesy/easyeda2kicad.py)",
)
)
Happy coding!