knipknap / better-tool-library

A FreeCAD addon and command line tool for managing tool libraries
MIT License
22 stars 11 forks source link

Adding Vendors catalogs #7

Closed ShamanTcler closed 10 months ago

ShamanTcler commented 1 year ago

I was looking for your import file format specs, and don't see them. (I did look under docs)

I would like to bring in catalogs from Whiteside & Bits&Bits.

Is there a JSON or such format you prefer? ( I already can make FreeCad tools and libraries but your BTL stuff is a mystery)

I know in a previous chat I said I was using CSV or Excel from vendors, because frankly most vendors don't understand anything more than that.

knipknap commented 1 year ago

The current import feature only supports the FreeCAD toolbit format (.fctb). Library import is not yet directly supported, which is probably what you would want. The CLI tool also has a Camotics import feature, but that is not yet exposed in the UI.

To add an additional import format, the following things would need to be done:

  1. Add a serializer in btl/serializer/. The serializer would probably look similar to camoticsserializer.py, but you can leave out unsupported methods. In other words, if you want to support import only and no export, you don't have to implement any serialize*() methods.
  2. I assume you want to import the tool list as a library, so you would need to extend btl/ui/library.py to have an extra menu item "Import Library", and a callback method "on_import_library_clicked()" to go along with it.

That would be pretty much it. I guess ideally there would be a dialog to preview the import, but that may be optional.

knipknap commented 1 year ago

Actually just implemented the UI for the Camotics importer, so now it's even easier to add your own importer:

  1. Add a serializer in btl/serializers/. For example, whitesideserializer.py. The serializer would look similar to camoticsserializer.py, but you can leave out unsupported methods. In other words, if you want to only support import and no export, you don't have to implement any serialize*() methods.
  2. Add your serializer to the list in btl/serializers/__init__.py

Done. It should automatically appear in the UI, meaning, when you click "File -> Import library", your serializer should show up in the file filter dropdown box of the file selector.