New group of extensions related to guides

Discussion about writing code for Inkscape.
User avatar
samueldellicour
Posts: 26
Joined: Mon Jul 01, 2013 11:03 pm
Location: Belgium
Contact:

New group of extensions related to guides

Postby samueldellicour » Fri Nov 07, 2014 4:13 am

In a previous post, I introduced an Inkscape extension to make a grid of guides. I've continued working on it, and I now have a series of Inkscape extensions related to guides, of which that grid extension is a part.

Full description (and download) on the Inkscape Guide Tools github page. Or use this direct download link.

NOTE: The latest version, release 2, is ONLY compatible with Inkscape 0.91, NOT with Inkscape 0.49.

If you're still using Inkscape 0.49, you need to download an older version: release 1. And re-download the new version of the extension when upgrading to Inkscape 0.91.

The current extensions in this package are:

- Add centered guides
- Add margin guides
- Add grid guides (formerly Grid Maker)
- Remove all guides
- Remove selected guides

Where to find the extension menu items

Once installed, the extensions will all be available in the menu under Extensions > Guide. Full installation details on the extensions page.

Image

1. Add centered guides to the document

With this extension you can quickly add a horizontal and/or vertical guide through the center of the document.

Image

2. Add margin guides to document

Inkscape already allows you to add guides exactly on the borders of the page, with Edit > Guides around page. With this extension you can add guides at a certain distance (margin) from the borders of the document.

Image

3. Add grid guides

This extension (previously released as Grid Maker) will generate guides in a grid of equal width columns (or rows) with gutters (spacing between columns). Use any unit (pixels, mm, etc).

Example 1: Columns (vertical guides), with gutters, centered on the document

Image

Example 2: Rows (horizontal guides), gutters set to 0, top aligned

Image

This extension was conceived as a tool for grids in designing websites in Inkscape, using pixels. But it now works with other units too (mm, in, etc).

The Add Grid Guides is heavily based on the code from Grid Creator, part of Inkscape core, under Extensions > Render. Many thanks to that extension's maintainer.

4. Remove all guides

This extension is actually made by heathenx (see his blog post), bundled here with his permission. I've just moved the extension's menu item to Extensions > Guides; this functionality may become part of inkscape in upcoming version [del]0.49 0.91. (no user interface, so no screenshot)[/del]

Removed, as you can remove all guides with Inkscape 0.91: Edit > Delete all guides.

5. Remove selected guides

Selectively remove all horizontal and/or vertical and/or angled (diagonal) guides. Based on heathenx's extension Remove all guides.

Image

I have made them separate extensions, grouped under the menu item "Guides", for clarity, and to not be overwhelmed with options. With the added benefit of the possibility of giving them a keyboard shortcut (explained in more details on the extension's page) to speed up repetitive work. I do realize that the existing core extension "Grid Creator" is in a different menu (under Extensions > Render), which is a bit unfortunate.

That's it! I hope others will find them as useful as I did.
Last edited by samueldellicour on Sun Feb 15, 2015 4:41 am, edited 2 times in total.
Samuel

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: New group of extensions related to guides

Postby Lazur » Fri Nov 07, 2014 5:30 am

Looks great!

Just a note that the upcoming version will be 0.91 instead of 0.49.
More importantly, it will have new guide features too:
  • Guides can now have labels, and the colour of individual guides can also be set by the user.

http://wiki.inkscape.org/wiki/index.php/Release_notes/0.91

If you could add the possibility to choose colour and label into the extension, it would mach with the new release the best.

User avatar
samueldellicour
Posts: 26
Joined: Mon Jul 01, 2013 11:03 pm
Location: Belgium
Contact:

Re: New group of extensions related to guides

Postby samueldellicour » Fri Nov 07, 2014 6:40 pm

Good idea, Lazur URH. I'll look into that.

It also looks like I'll have to update how units are being calculated. For now, the extensions work in 0.49, but have not been tested in (upcoming) 0.91.

Inkcape 0.91 looks to be a great new version.
Samuel

elecman
Posts: 27
Joined: Mon Feb 09, 2015 1:39 pm

Re: New group of extensions related to guides

Postby elecman » Thu Feb 12, 2015 6:03 pm

Can you add an option to create a guide in the middle of two other guides?
That would be very helpful.

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: New group of extensions related to guides

Postby tylerdurden » Thu Feb 12, 2015 11:05 pm

In the meantime, there are some easy methods:

If you know the distance between the two ("n"), another guide can be snapped to an existing, then offset relative by editing (click 2x) and the value can be entered as an expression, i.e "n/2".

A rectangle can be created snapping to the existing guides and a new guide can be snapped to its center.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: New group of extensions related to guides

Postby Lazur » Thu Feb 12, 2015 11:57 pm

Middle of two guides?

Hmm. If it's for horizontal/vertical guide lines, there is a way simple solution.

Like, there are two horizontal guide lines.
Drag one vertical one from the left ruler, then drag one from the top ruler's right and left edges for guide lines in 45° and -45°, and snap them to previous guide line intersections.

After that, snap a new horizontal guide line to the two diagonal guide line's intersection.

elecman
Posts: 27
Joined: Mon Feb 09, 2015 1:39 pm

Re: New group of extensions related to guides

Postby elecman » Fri Feb 13, 2015 12:23 pm

Thanks so much guys! These are all good methods to do what I want.

User avatar
samueldellicour
Posts: 26
Joined: Mon Jul 01, 2013 11:03 pm
Location: Belgium
Contact:

Re: New group of extensions related to guides

Postby samueldellicour » Sat Feb 14, 2015 9:44 pm

If you use my guides extension (mentioned at the beginning of this thread), you can generate those middle guides too, but it does take one extra step. Generate an extra grid of guides, with gutters set to 0, and with the right width for columns.

So after generating the original columns and gutters, generate a new grid with gutters set to zero, with column width set to [original column width + gutter width] - this will generate the centered guides in your gutters.
If you need centered guides positioned on round pixels (for web design), be sure to use an even number for the gutter width in the original grid.

For example:
1. Say you use the extension to make a 12 column grid, with columns width 56px, gutter width 20 (even number if it's for webdesign). Apply the grid.
2. Now make a new grid, 12 columns, with column width 56+20 = 76px, gutter set to 0. Apply. Bam! Now you have all your middle guides.

Hope this helps.

Note: the extension is not compatible with Inkscape 0.91 yet, I'm working on it.
Last edited by samueldellicour on Sun Feb 15, 2015 12:58 am, edited 1 time in total.
Samuel

User avatar
samueldellicour
Posts: 26
Joined: Mon Jul 01, 2013 11:03 pm
Location: Belgium
Contact:

Re: New group of extensions related to guides

Postby samueldellicour » Sun Feb 15, 2015 12:56 am

I have updated the extensions, and they are now compatible with Inkscape 0.91.

I'll see if I can add those "middle guides" in the gutters as an option...
Samuel

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: New group of extensions related to guides

Postby ragstian » Sun Feb 15, 2015 1:08 am

Hi.
Nice set of extensions.

Getting some error messages related to unit to user unit function;

    Traceback (most recent call last):
    File "add_centered_guides.py", line 118, in <module>
    effect.affect()
    File "C:\Users\ragnar\AppData\Roaming\inkscape\extensions\inkex.py", line 215, in affect
    self.effect()
    File "add_centered_guides.py", line 102, in effect
    canvas_width = self.unittouu(svg.get('width'))
    AttributeError: addCenteredGuides instance has no attribute 'unittouu'

The code self.unittouu has to be replaced with inkex.Effect.unittouu, or, it has to be moved into the effect part.
See this; http://wiki.inkscape.org/wiki/index.php ... ing_change
and this; viewtopic.php?f=34&t=18034
Last edited by ragstian on Sat Feb 28, 2015 3:22 am, edited 1 time in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

User avatar
samueldellicour
Posts: 26
Joined: Mon Jul 01, 2013 11:03 pm
Location: Belgium
Contact:

Re: New group of extensions related to guides

Postby samueldellicour » Sun Feb 15, 2015 4:35 am

@ragstian:

I had seen those posts. I have replaced inkex.unittouu with self.unittouu - contained in Class addCenteredGuides(inkex.Effect) and it works for me (Windows, Inkscape 0.91).

Are you using Inkscape 0.91 or 0.48?
The latest versions are only compatible with 0.91. I should have made that more clear. I'll update the description.

Please be sure to download the latest version, as I made some corrections today, and try again.

For Inkscape 0.48, you'll need to use the old version (release 1), also available on the download page (github).
Let me know how it goes.

@elecman:

I have added the option to add centered guides inside gutters ;-) (latest version, for Inkscape 0.91 only). If it's for web design and these middle guides need to be positioned on the round pixel, be sure to set the gutter width to an even number.
Samuel

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: New group of extensions related to guides

Postby ragstian » Sun Feb 15, 2015 7:46 am

Hi.

Thanks for the info, I found the problem.
For some reason the inkex.py ( my idiot error) file had made it's way into my user extension directory.
After removing it the extensions works like a charm.
Sorry about the confusion my previous post might have caused!
Last edited by ragstian on Sat Feb 28, 2015 3:21 am, edited 1 time in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

elecman
Posts: 27
Joined: Mon Feb 09, 2015 1:39 pm

Re: New group of extensions related to guides

Postby elecman » Sun Feb 15, 2015 8:11 am

samueldellicour wrote:@ragstian:
I have added the option to add centered guides inside gutters ;-) (latest version, for Inkscape 0.91 only). If it's for web design and these middle guides need to be positioned on the round pixel, be sure to set the gutter width to an even number.


Wow, thanks so much! That surely speeds up my workflow.

danyill
Posts: 1
Joined: Mon Apr 17, 2017 5:19 pm

Re: New group of extensions related to guides

Postby danyill » Mon Apr 17, 2017 5:25 pm

I've done a little work on this extension to make it work with Inkscape 0.92.1 and also to allow centering and margin guides of an arbitrary selection. I've reworked a little code to speed up operations.

For anyone interested, see a fork from the original here: https://github.com/danyill/inkscape-guide-tools

You'll need to download and install from the repo rather than the download link in the Readme (which still refers to the original author's work).

Happy to take feedback from anyone :-)

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: New group of extensions related to guides

Postby Maestral » Mon Apr 17, 2017 9:25 pm

Unfortunately, it also does not work on 48.5
Duplicate options on drop-down menu and some errors reported when deployed.

I followed your remark regarding the working versions (48.0 and earlier) but apparently it includes 48.5 as well.
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:


Return to “Programming”