FR: API for Scripting
-
Hi,
Is an API with a simple scripting language (like Lua or JavaScript) in consideration for VectorStyler ?
It is really something which is missing from Affinity Designer and as been requested for years.
Even a very simple system, with a dropdown to run file from a directory could do nice things.
Having access to Layer stack, layer name, layer transform properties, and we can write some nice things with that, to make grids, to add randomization etc...
It is surely not in top priority cause there is stability and UX things to take care first but just wanted to know if this is something dev have considered.
Thx!
-
@X-Raym I'm positive a scripting API is coming — in the meantime Actions (Panels > Presets) while limited, can be put to good use.
-
@X-Raym The short answer is yes, but it will be in a major update (possibly before 2.0, but certainly by 2.0).
The longer answer: both native plugin development and scripting already exists in the current version of VectorStyler, it is just not publicly available (so the hard part is done).
And in fact, the whole VS as it is, is a collection of plugins.
The problem is that this API cannot be made publicly available, as it would restrict its evolution (fragile binary interfaces).
For native development, there will be an additional layer of indirection (in C++), publishing a restricted, but sufficient interface to develop various plugin types (effects, file formats, actions, etc).
For scripting (Lua is already in, again internally only), the primary target is JavaScript, with a set of domain specific interfaces (mainly focused on automation, access to document hierarchy, styles, effects, and properties in general).
-
This is promising, and nice to hear it is in consideration ! Thx!
-
@vectoradmin Quick question on this: I know, these things are incredibly hard to predict, but do you have any rough estimate when 2.0 might be released?
-
@Nils said in FR: API for Scripting:
@vectoradmin Quick question on this: I know, these things are incredibly hard to predict, but do you have any rough estimate when 2.0 might be released?
Yes, it is hard to predict. There is a set of features that are planned to be done before that.
But bugs are always prioritized over features, and then there are also those feature requests that are "almost bugs", in that it is either something missing, or it is an obvious thing that is needed.So I prefer to keep the schedule fluid, so I cannot assign a date to 2.0.
I have been planning to setup a roadmap (without dates) of features, so progress can be followed much better.
-
@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 ).
-
@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..
-
@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
-
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
-
@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 .