FR: API for Scripting



  • @vectoradmin Makes sense. Quick aside: If you ever considered to provide a python interface for the eventually coming scripting API, that would be amazing. It's imo a way better language for this kind of thing.



  • @vectoradmin

    You already mentioned Lula and Java Script, which of the
    two is from your point of view the scripting language that
    offers the most possibilities in Vs?

    I have some (amateurish) knowledge of various scripting languages, including Lua.
    Have always enjoyed using these to automate operations.

    Lua seems to me to be a bit easier than Java Script for beginners (myself included 🙂 ).

    Bwt. while @Nils wrote this, have no knowledge in Phyton. ( yet 🙂 ).


  • administrators

    @Subpath @Nils The current architecture of VS allows the addition of scripting languages as plugins.

    Currently only Lua is implemented, but it is not public. JavaScript is certainly will be added, and from what I know Python is also possible.

    The (native) interfaces to VS are dynamic and it is easy to create / call any object or method from a scripting language, or navigate existing object hierarchies like the document.

    The main challenge is to select what interfaces to publish, and document those, this where the actual effort will be.



  • @Subpath Hey, you should pick up some python when you find some time. It's really easy to learn and a lot better for these purposes. For example: Inkscape uses it for their extensions and it works beautifully. Since VS is in most other aspects a lot better than Inkscape ( expectedly, since it's paid ), this would really widen the gap a lot.



  • @vectoradmin I see, so I imagine the backend document structure manipulation to be similar to your typical svg xml doc..


  • administrators

    @Nils said in FR: API for Scripting:

    @vectoradmin I see, so I imagine the backend document structure manipulation to be similar to your typical svg xml doc..

    Yes, there are properties to get/set, collections to iterate over. Properties can get a bit more complicated, but otherwise it is a typical document object structure.
    Except the structure is not strictly defined. A lot of plugins participate and bring their own data / properties / features.



  • @vectoradmin

    thanks, interesting



  • @Nils

    I know that Inkscape have Python as Scripting Language
    also use Inkscape from time to time. Like the Spray Feature in Inkscape.
    I will have a look at it when I have some time


  • administrators

    @Nils @Subpath BTW: the VS document can be saved in JSON or XML format (it is a variation of the same vstyler format), by setting JSON or XML in Document Setup -> File -> File Format field.

    The resulting file can then be used with any JSON or XML tool. But, no documentation on the content



  • @vectoradmin

    interesting, but it's out of my league. I have dealt with html once, but it's been a looong time 🙂 .