Inkscape.org
Creating New Extensions Open extension with extern database.
  1. #1
    Mateocasa25 Mateocasa25 @Mateocasa25

    Hi. I am working on an extension, derived from the existing "plot". And I would like to add a database with the material configuration parameters, since it is for a laser cnc and each material has more than 10 parameters, speed, frequency, pulses, power ..... etc. I would like to know where I can look for some examples or tutorials, to get an idea. I have a basic level of programming. Thanks for your time.

  2. #2
    Martin Owens Martin Owens @doctormo🌹🧀

    You need to have a database like a table of figures?

    I would load data as json format. This is because it will retain the basic data types of numbers, booleans etc and you won't have to do so much converting compared to formats like csv.

    import json
    import inkex
    
    class MyExtension(inkex.EffectExtension):
        ...
        def get_my_data(self):
            data_file = os.path.join(self.ext_path(), "my_data.json")
            with open(data_file, "r") as fhl:
                return json.loads(fhl.read())
        ...

    This snippet shows how to load a json data file from the same directory as the extension's own folder. So ship the data file alongside the inx and py files.

  3. #3
    Mateocasa25 Mateocasa25 @Mateocasa25

    Thank you, it is what I was looking for a basis to start work and learn something. Great community and its people. and sorry for my bad english.

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Open extension with extern database.