I'm triying to write an extension that create linked path offsets,
I did find any way to actualy do the calculation of path offset in an extension, but I found simply creating new <path> with the same attributes than what the linked offset tool do, but without any "d" attribute, does the job...
Inkscape renders correctly the offsets when it receives it from the extension, live preview works great also. When the effect is applied, the new <path>s are correctly created and offset applied. The offsets are well linked to the original object and updates when the later is modified, everything works...
But there is an update issue: the actual "d" attribute is never wrote in the document, neither in the XML editor shows it, neither in the saved document opened in a texteditor. Even if Inkscape actually shows the good offset path.
Then if I hide/show an offset, now the "d" attribute is populated :O
If I save/close/reopen the file, the offsets are still well rendered, but the "d" attributes are missing still ...
Anyone know what I am doing wrong? Or if there is a way to tell Inkscape to update/check the document to validate dynamic object?
And after hiding an offset <path> (note the 1st time the object is still "display:inline", the "d" attribute is populated, the 2nd time hiding actually set "display:none")
Thanks for your clarifications on non-SVG attributes, but I could figure out this already :) (I'm a web-dev so I already had to look at all this).
I had done also some JS stuff to add <path> nodes with linked offset attributes, without the "d" attribute still. It was done outside inkscape (obviously) and saved on disk. When re-opening this modified SVG in inkscape, it detects correctly the "dirty" offsets, update it by populating the right "d" attr and then saving the file again saves it correctly.
I am just triying to do the same in an inkex extension right now...
When you use the UI's linked offset tool, the "d" attribute is populated, and then present in the markup that is saved.
I would like to preserve the dynamicaly linked feature and not "raster" the path for later original path modifications to be reflected on the generate offsets...
- In the extension on the created offset pathes: do populate the attribute "d" by copying the original path "d" (so without real offset) >> same same, "d" attr is not updated, the wrong one is saved
- In the extension on the created offset pathes: do not populate "d" atttribute neither "inkscape:original" >> same same, "inkscape:original" is populate by inkscape though, but not the "d" one still
I found a workaround: hide/show the parent group, or any parent hierachy do populate the "d" attr on each offsets !! That is way less a pain that having to do that on each offset...
Hi all !
Inkscape is a wonderfull software :)
I'm triying to write an extension that create linked path offsets,
I did find any way to actualy do the calculation of path offset in an extension, but I found simply creating new <path> with the same attributes than what the linked offset tool do, but without any "d" attribute, does the job...
Inkscape renders correctly the offsets when it receives it from the extension, live preview works great also. When the effect is applied, the new <path>s are correctly created and offset applied. The offsets are well linked to the original object and updates when the later is modified, everything works...
But there is an update issue: the actual "d" attribute is never wrote in the document, neither in the XML editor shows it, neither in the saved document opened in a texteditor. Even if Inkscape actually shows the good offset path.
Then if I hide/show an offset, now the "d" attribute is populated :O
If I save/close/reopen the file, the offsets are still well rendered, but the "d" attributes are missing still ...
Anyone know what I am doing wrong? Or if there is a way to tell Inkscape to update/check the document to validate dynamic object?
Thx
Inkscape v1.3.2
And after hiding an offset <path> (note the 1st time the object is still "display:inline", the "d" attribute is populated, the 2nd time hiding actually set "display:none")
You have not done anything wrong.
Inkscape is closely linked to the SVG format specification.
So, how do we add extra functionality to the file format and still keep to the SVG spec ?
The answer is tags / attributes / properties which are ignored by 3rd party software - (browsers editors etc)
This can be done a couple of different ways, however in Inkscape it generally uses the inkscape or sodipodi namespace.
For example, at the top of an Inkscape SVG (not plain SVG) you will see:
<sodipodi:namedview............/>
When using the Polygon tool, you will see a series of sodipodi:foo and inkscape:bar attributes.
The Polygon tool, just like your offset example also has 'd'.
However, Inkscape does not need 'd' for some shapes ( unless the shape or linked offset is converted back to a path ).
The 'd' attribute is there for compatibilty with the SVG specification when the file is saved.
It is regenerated internally when the main Inkscape program detects certain changes.
------------------------------------
Inkex is Python it simply process the SVG sent to it, and returns another.
It cannot to my knowledge trigger these changes in the main program. ( it does have has_changed but that is for use with inkex only )
------------------------------------
The only way I have found to force the regeneration of 'd' is by either:
Using a command call - object to path for example and transplanting the 'd' from the returned path to the original object
Or (probably best avoided)
Using a dbus call directly to the gui, moving an object, then move it back again.
Thanks for your clarifications on non-SVG attributes, but I could figure out this already :) (I'm a web-dev so I already had to look at all this).
I had done also some JS stuff to add <path> nodes with linked offset attributes, without the "d" attribute still. It was done outside inkscape (obviously) and saved on disk. When re-opening this modified SVG in inkscape, it detects correctly the "dirty" offsets, update it by populating the right "d" attr and then saving the file again saves it correctly.
I am just triying to do the same in an inkex extension right now...
When you use the UI's linked offset tool, the "d" attribute is populated, and then present in the markup that is saved.
I would like to preserve the dynamicaly linked feature and not "raster" the path for later original path modifications to be reflected on the generate offsets...
I'm not sure to understand this solution? Could you elaborate on this please? (maybe point out any documentation)
THX for your reply BTW ;)
I just tested some stuffs:
- Update to Inkscape 1.4 >> same same
- In the extension on the created offset pathes: do populate the attribute "d" by copying the original path "d" (so without real offset) >> same same, "d" attr is not updated, the wrong one is saved
- In the extension on the created offset pathes: do not populate "d" atttribute neither "inkscape:original" >> same same, "inkscape:original" is populate by inkscape though, but not the "d" one still
I found a workaround: hide/show the parent group, or any parent hierachy do populate the "d" attr on each offsets !! That is way less a pain that having to do that on each offset...