spakin / SimpInkScr

Simple Inkscape Scripting
https://inkscape.org/~pakin/%E2%98%85simple-inkscape-scripting
GNU General Public License v3.0
330 stars 32 forks source link

How to automate the creation of guides #45

Closed haschdl closed 2 years ago

haschdl commented 2 years ago

Thank for such great extension! I would like to automate the tedious work of creating guides. I usually create the same guides, at 10% of the size, plus 13% bottom margin and a final guide at 7% height. Is there a function to create guides? I couldn't find in the documentation.

spakin commented 2 years ago

I'm glad you like Simple Inkscape Scripting. Guides would be a great addition to the extension. I'll implement those when I get a chance. In the meantime, try something low-level like this:

g = inkex.elements.Guide()
g.move_to(width/2, height/2, 45)
nv = svg_root.namedview
nv.add(g)

The move_to method is the key. It takes the x and y position for a point on the guide and an angle in degrees by which to rotate the guide.

spakin commented 2 years ago

Simple Inkscape Scripting now provides a guide function for creating guides and a guides list that keeps track of all of the guides in the document. See Guides in the wiki for details.

haschdl commented 2 years ago

Thank you @spakin , i will learn how to use the new feature, I’m sure it will save me a lot of time!