Stroke to Path? #100
-
Is there a way to call the Path -> Stroke to Path functionality? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I found a partial solution for you: for obj in selected_shapes():
svg = svg_root.tostring()
iobj = obj.get_inkex_object()
new_svg = \
inkex.command.inkscape_command(svg,
select=iobj.get_id(),
actions=['object-stroke-to-path'])
loaded_svg = inkex.elements.load_svg(new_svg)
extension.document = loaded_svg The idea is to spawn a separate Inkscape (using Inkscape 1.3's The reason this is only a partial solution is that Simple Inkscape Scripting does not know that the SVG file has changed and that some new objects are available and some old objects have disappeared. Hence, a script cannot perform further operations on an object whose stroke was converted to a path. Perhaps a future version of Simple Inkscape Scripting will provide the internal mechanisms to launch a child Inkscape and recreate all Simple Inkscape Scripting objects upon its return, but I can't promise anything. |
Beta Was this translation helpful? Give feedback.
-
Thanks, that's indeed a partial solution. In my case the full thing I wanted to do was automate the removal of the stroke from the background of many objects (since the stroke is halfway over the fill), so my manual process was to do (1) stroke-to-path, (2) ungroup, (3) difference. For now, I used an external program to automate sending the hotkeys for those three actions, and just slogged through selecting the many objects and sending those hotkeys. It would be cool to be able to access actions from SimplInkScr directly, but if I understand you correctly, Inkscape is missing some extension API stuff to make that easily available. Thanks for your help though :) |
Beta Was this translation helpful? Give feedback.
Good news! I believe I managed to implement a means of invoking arbitrary Inkscape actions from a Simple Inkscape Scripting script.
I introduced an
apply_action
function, which invokesinkscape_command
as in the partial solution but then patches Simple Inkscape Scripting's state so it's aware that the document has changed from under it.Documentation for
apply_action
is available under Inkscape actions in the Simple Inkscape Scripting wiki.Please download the latest version of the code from the GitHub repository and let me know if this provides the functionality you were looking for.