1

How does Inkscape handle nodes in scripting? Or can the nodes be written out in some way? Or perhaps there is a better place to ask about this:

I have a simple manual clicking routine that seems a good candidate to automate using Inkscape scripting:

Image of several circles each centered on different points on a bezier curve

  1. Draw one circle.

  2. Move the circle so the center snaps onto the first node in a list.

  3. Repeat for the next node until the number of nodes is reached.

This works so far, thus my interest in Inkscape, however, there are a number of problems that I think will be solved if the nodes are worked with differently. I have read/tried:

GitHub repository: Simple Inkscape Scripting

Also see:

... as well as the documentation. So far, SimpInkScr works great but apparently does not work with nodes. I wonder if perhaps Inkscape can somehow write out nodes as points in a file to work with outside Inkscape.

programs used:

  • Inkscape v 1.1.2

  • Ubuntu Linux 22.04.2

  • SimpInkScr: not sure of the latest version number, but it is as of Feb. 21, 2023.

I also just found:

How can I automatically draw a circle on each node of a path in Inkscape?

update/progress:

.. if this is outside the scope of this user group, I apologize - perhaps Stack Overflow is better - but back to the svg question :

This describes paths in the svg file. This describes the basic shapes.

I can put circles around nodes in a path by editing the svg file. there are pairs of coordinates. This will work perfectly with command-line tools (awk,sed,bash,..) if the relationships between "m", "c", "l",.. and the pairs of coordinates can be maintained. I will try to put an example image up of a testing case - with an errant circle.enter image description here

relevant svg code snippet for the above image:

    <!-- the circle is here
     Inkscape gui says:
     x,y = 50.000,50.000 mm
     W,H = 120.000,120.000 mm
     110.000,110.000 is center and a line node
     110.000,230.000 is where the line ends
     -->
    <circle
       style="fill:none;stroke:#ff0000;stroke-width:0.262654"
       id="path846"
       cx="110"
       cy="110"
       r="59.868671" />
    <!-- another circle centered on the end of the line with 2r -->
    <circle
       style="fill:none;stroke:#ff0000;stroke-width:0.262654"
       id="circle5"
       cx="110"
       cy="230"
       r="120" />
    <!-- try circles centered on things -->
    <circle
       style="fill:none;stroke:#ff0000;stroke-width:0.262654"
       id="circle6"
       cx="154.68248"
       cy="194.63248"
       r="30" />
    <circle
       style="fill:none;stroke:#ff0000;stroke-width:0.262654"
       id="circle6"
       cx=""
       cy=""
       r="30" />
    <!-- now the path with some nodes -->
    <path
       style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       d="m 110,110 38.04426,11.79937 6.63822,72.83311 L 110,230"
       id="path1062"
       sodipodi:nodetypes="cccc" />
    <!-- end of path with some nodes -->

1

1 Answer 1

0

This Graphic Design SE post will be very useful for this question. It is still not clear how scripting is handled in Inkscape (e.g. loading a script into a window or some such), but it might not matter because the command-line scripts (amenable to "automation") and Inkscape GUI tools referred to in the linked SE post will be of great value to get/edit/add 1. nodes and 2. calculate plain-text format x,y coordinates of a curve or other vector features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.