Outils pour utilisateurs

Outils du site


issue179:inkscape

Ceci est une ancienne révision du document !


They did it again! Literally the day after the deadline for last month’s article, the Inkscape developers released a new version. It’s only a maintenance and bugfix release (version 1.1.2) with no new features, so I won’t be covering it in any more detail, but if you’ve already upgraded to the 1.1 series, it’s probably worth installing this latest version for improved stability. Alongside this release was an alpha version of Inkscape 1.2. If you have the time and inclination, I do recommend giving this release a try and reporting any issues you find, particularly in the new features. The more that users report problems with the alpha and beta releases, the more stable the final release is likely to be. Information about both these releases can be found on the official Inkscape news page: https://inkscape.org/news/

This month, I’ll be looking at just one Live Path Effect (LPE) that was added in version 1.0: Measure Segments. This LPE operates so differently to most that I won’t have enough space to cover everything in one article. This time, I’ll look at the practical functionality of the effect, and next month, I’ll dig into some of the more technical details of how it works.

Measure segments

At first glance, the Measure Segments LPE seems fairly straightforward – albeit with a lot of parameters to consider. It measures the straight line distance between the nodes of your path, and annotates your image with those dimensions. This is definitely a case where a picture is worth a thousand words: in this image my original path is the red line, and the rest of the content has been generated by the LPE.

The most interesting thing about this image is that I was able to color my original path in red without the need to use the Clone Original LPE, or any equivalent technique or workaround. The styling of the original path is distinct from the styling of the dimensions. Long-term readers of this column will know that this flies in the face of everything we know about LPEs. Historically, the output from an LPE has been a single path – albeit often a very complex one – meaning that all the different parts of an effect would have to adopt the same styling. Clearly there’s something very different going on in this case, but I’ll get back to that next month.

For now, let’s just take the effect at face value, and have a look at some of the parameters we can tweak in order to adjust its output. For this LPE, there are so many that they have been split across three tabs – plus a fourth “Help” tab that doesn’t really provide any more information than can be gleaned from the tooltips.

Starting with the General tab, the Unit pop-up is pretty self-explanatory. It’s restricted to the units that Inkscape uses throughout the software, so if you’re trying to create a scale drawing in miles or microns you might think you’re out of luck. In practice the format of the numeric labels is defined over on the Options tab, so you can get around this limitation by replacing the “{unit}” placeholder with a fixed string of your own. For example you could set the Label Format field to “{measure} miles” or “{measure}µm” to mark the dimensions in units that Inkscape doesn’t support.

Back on the General tab, there is another field that should go hand-in-hand with the Unit pop-up, but which has been counter-intuitively put towards the bottom of the dialog: the Scale field. This acts as a multiplier for all the numeric values, so if your original drawing is half-size, you should set this to 2; conversely if your drawing is double-size, set it to 0.5, and so on. You can even enter a negative value here, though I’m not sure why you would want to.

Most of the remaining fields on this tab simply adjust the specific appearance of the dimension lines and labels. You can use the Font pop-up to change the font and size; the Position field to adjust how far away the dimension line is from the path being measured; the Flip Side checkbox to select which side of the path the dimension is drawn; the Label Position field to change the position of the numeric value relative to the dimension line, allowing it to sit on top of or below the line (in which case you might also want to uncheck the “Hide line under label” option). To be honest, the best approach is just to play around with these fields in order to see what they do – using the tooltips if you need a hint – but in my experience the default values tend to give pretty good results.

The one widget that I don’t understand is the Merge Overlaps field. No matter how I draw my paths, whether with long or short segments, or with tight or wide angles, I can’t get this field to have an effect. If anyone can provide some insight into what this field does, please let me know.

I’m going to skip the Projection tab for now, and go straight to Options. This is a mish-mash of fields, some of which would seem to relate closely to those in the General tab, but which have been hidden away here instead. The Color and Opacity picker, for example, seems to me to be a sensible companion to the font picker. This widget sets a single color that is used not only for the dimension lines, but also the leader lines (“Help lines” as they are named in this extension), and the dimension text.

In the same vein, the Precision and Label Format fields surely deserve to live alongside the Unit and Scale widgets. Note that the Precision field just sets the number of decimal places in the text labels. There’s no way to use significant figures rather than decimal places, and there’s no facility for engineering or scientific notation.

Similarly misplaced is the “Multiply values < 1” checkbox, which is used to better display very small values by multiplying them by 100 and omitting the auto-inserted units from the text (but it won’t omit the units if you’ve used a fixed string in the Label Format field, as I described earlier). This should arguably also live with the Scale and Units fields. The Hide Arrows checkbox is just as deserving of a place on the General tab as most of the checkboxes at the bottom of that pane.

None of this arbitrary placement of widgets is a deal-breaker, but it’s useful to be aware that the Options tab provides these features. Perhaps a later release will tidy up this effect’s UI, and better group the controls into more logical sections.

Also on the Options tab are what I consider to be the “sneaky” controls: three fields that radically increase the capabilities of this effect, albeit at the expense of a little extra effort on the part of the user. The most important of these is the Blacklist Segments field, which takes a comma-separated list of numbers, and uses those values to suppress the output of the LPE for specific path segments. Here’s how the earlier image looks when the string “1,2,4” is entered into this field and the tick button is clicked.

You can see that there are no longer any dimension lines rendered for three of the path segments. The three segments are not, however, the first, second and fourth ones in this path. Rather they are the second, third and fourth: the values start at zero for the first path segment in a classic example of a programmer exposing the internal indexes that the software uses, rather than adjusting them to be more user-friendly to the layman.

As you might imagine, working out which segment index you need to use to target a specific part of the path can quickly get tricky with complex shapes, but this LPE does offer a feature to help. Enabling the “Show segment index” checkbox will prefix each dimension with the segment’s index, in square brackets. Be aware that it unfortunately doesn’t show the index for any segments that are already listed in the Blacklist field, so you may want to enable this option first, while that list is still empty. With no blacklisted segments, and this checkbox enabled, you can see that indexes 1, 2 and 4 do indeed correspond to the omitted dimensions on the previous image.

One thing to be very conscious of is that the segment indexes are based on the direction in which the path is drawn. If you use the Path > Reverse menu entry, you’ll find that the indexes run in the opposite direction, probably requiring you to adjust the blacklist. Similarly, if you add or remove any nodes then the indexes of some of the segments will also change.

Due to the political sensitivity around certain terms used in computing, there’s a good possibility that the “Blacklist segments” field might be renamed in future. Often “blocklist” is used instead, but I think in this case calling it “Skip segments” or something similar would give a better idea of its functionality. I’m mentioning this because of the last of the sneaky controls: Invert Blacklist. Checking this turns the blacklist into a whitelist – or, more descriptively, turns the “skip segments” list into a “draw these segments” list. This may save you having to enter a long list of segment indexes when you only want the LPE to render a small number of segments from a complex path. With this applied, you can see that my list of “1,2,4” actually results in only those segments being drawn, rather than those segments being omitted.

So why do I consider these three fields (Blacklist segments, Invert blacklist, Show segment index) to be “sneaky”? It’s because they allow you to apply this same LPE to a path multiple times, each using different parameters, using the blacklist fields to ensure that each copy of the effect targets a different subset of the path segments. Perhaps you need to color-code different measurements, alter the label format for one segment, or simply move the position of some dimensions so that they don’t clash with other parts of the image. Using these fields will let you achieve all that and more.

Here, for example, I’ve used two copies of the LPE. The first colors three of the dimensions in purple. The second uses the same blacklist, but with the Invert box checked, in order to target the remaining dimensions. These are then drawn in blue, with a thicker line width, arrows on the outside of the extension lines, and a tolerance value added by manually altering the Label Format field.

Now let’s return to the Projection tab that we skipped earlier. I’ll admit that this one has me a little stumped. When the “Activate projection” checkbox at the top is enabled, every node in your path is projected in an invisible straight line along the specified “Angle of projection”, with the final dimension lines showing the distances between those projected lines. As you can see from this screenshot, however, the default behaviour may not be terribly useful, depending on the shape you’re trying to measure, and the angle of projection you use.

There is a section in this tab to which you can add other objects, by copying them to the clipboard and using the Link to Item button, as happens in other LPEs. According to the tooltip, the nodes of those objects should then be projected onto your path in order to produce datum points for additional measurements. In practice, I haven’t been able to get this feature to work at all, regardless of what I tried. If anyone has some insight into how to use this facility, please do get in touch.

The Blacklist Segments field can be used with projection mode, but the numbers in there are no longer the indexes of the path segments. Instead this allows you to turn off individual projected measurements. Once again the “Show segment index” checkbox can be used to identify the correct numbers to use. Also once again, this allows you to combine multiple copies of this LPE, with different projection angles, or mixing both projected and non-projected dimensions to produce the result that best suits your needs.

While the Projection tab might initially look useful, in cases where you only want to project dimensions along the horizontal or vertical directions you may well find that the Orientation pop-up on the General tab lets you achieve a better result – though you’re likely to need to use multiple instances of the LPE, each targeting specific segments, in order to get things exactly as you want them. Here’s another copy of our dimensioned path, this time using the Orientation pop-up to produce the green dimensions at the top left. In this case I had to add two more instances of the LPE, one for each orientation, with both targeting the same single segment.

This really is a very powerful LPE, with a lot of flexibility built into it. It’s a shame that there’s not also a corresponding LPE for measuring angles, but perhaps that will come in future. Although this may give the impression of adding more CAD features into Inkscape, I see it more as a means of annotating simple sketches, rather than producing production ready designs. I’ve always maintained that Inkscape is a primarily artistic program, and if you want real CAD capabilities then you’re better off learning to use FreeCAD or some other dedicated application.

In this article, we’ve seen what this LPE is capable of – including different fonts and multiple colours that aren’t the same as the source path. The way it achieves this is radically different to the way most LPEs work, and I’ll be looking at the details of that – together with the problems it brings – next time.

issue179/inkscape.1648385876.txt.gz · Dernière modification : 2022/03/27 14:57 de auntiee