Inkscape.org
Creating New Extensions Callback on path modification or other solution for timestamping
  1. #1
    inscing inscing @inscing

    I'm moreso looking for a solution to a problem and would prefer to implement it on top of a gold-standard FOSS solution like Inkscape. I've done some brief searches and skimmed the documentation but can't find any clear indication of whether this is possible before I invest more time.

    Is there a means to register a callback to a function, such that it is called every time a path property is modified. Very specifically, I'm looking to add timestamps as a separate, parallel property to path elements that align with/match every entry in the 'd' property such that the timecourse with which a line is created is also captured, so it can later be extracted and scrutinized. Imagine if you intended to embed timing metadata in a path to allow you faithfully animate the exact the timing with which each part of a line was originally drawn. In this case it's more for assessing motor behaviors in a scientific setting after the fact, but the same implementation conceptually.

    I notice that there are Notify objects mentioned among the utilities in the API that allow arbitrary callbacks, but I'm not sure if this is applicable to my situation. I also notice a lot of objects in the API, like the inkex.paths.path object have callback attributes, but it's not clear to me if this is just for creating programmatically creating paths (vs implementing behaviors when users manually modify objects).

    If this isn't possible via the API and plugins/extensions, I would appreciate if someone could direct me to right part(s) of the source code where path drawing happens. I've been looking around and have found a bunch of instances where functions create "d" properties for paths, but haven't found any obvious loops or GUI callbacks where path objects and their "d" property are iteratively modified. This is likely because I am (hopefully understandably) very unfamiliar with how InkScape is implemented; the documentation overall seems very good. I get that it's a bit of an ask but if anyone familiar with the source code could point me in the right direction I'd be be content modifying the source and building a version to do this myself.

    Any help/direction is much appreciated!

  2. #2
    inklinea inklinea @inklinea⛰️

    The extension system is:

    -Gui sends current svg to the extension system. 
    -Svg is processed
    -Svg is returned
    ( You can generate svgs too, but it's very similar )

    If you need real time monitoring - you would need to alter the source code as far as I am aware.

    I would ask here https://chat.inkscape.org/channel/team_devel

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Callback on path modification or other solution for timestamping