Search & Replace

General discussions about Inkscape.
JuliaFlowers2
Posts: 40
Joined: Tue Jul 31, 2018 4:47 am

Search & Replace

Postby JuliaFlowers2 » Thu Aug 09, 2018 1:11 pm

Dear friends,

im trying to understand the search & replace dialogue.

All i could find on the topic is an article from the fullcirclemagazine which didnt help much.

What is really needed are examples !

I experimented with a bunch of randomly coloured stars and tried to find the black ones, but whatever i searched for, nothing came up.

I tried:
fill:#000000ff
000000ff
and what feels like countless variations of the same with added spaces or removed terms and digits.

So first question: how do i find a specific (not named) colour ?
Second question: what are the terms to search for other objecttypes (like elllipses, rectangles, etc) ?

Third question:
the Inkscape wiki gives several examples what should be possible and i have no idea how to perform any of these:
http://wiki.inkscape.org/wiki/index.php ... laceDialog

find all text objects where Times New Roman is used, substitute it with DejaVu Serif and move all these text object to a layer called "Text";
find all rectangles with horizontal/vertical radius between 50 and 70 and change it to 75;
find all stars of a given color with 25+ spikes and randomize them;
find all ellipses with given flat fill color and randomize that fill color between a given range of RGB/HSV/CMYK values;
find all guides with non-even values and round them.

Who can solve this ?

User avatar
Xav
Posts: 1209
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: Search & Replace

Postby Xav » Thu Aug 09, 2018 5:34 pm

Sorry you didn't find my FCM article to be much help.There's a lot to cover in Inkscape (I've been writing the articles for over 6 years now!) so some topics naturally just get a brief introduction rather than a full multi-article guide.

For finding the black stars, the best approach is not to use the Find dialog at all. Simply select one of the stars then use Edit ‣ Select Same ‣ Fill Colour.

If you do want to use the Find dialog for this, you were on the right lines, but understandably sidetracked by the way Inkscape defines colours. It uses hexadecimal RGBA notation in the Fill & Stroke dialog, but in the XML document they're split into separate RGB and A components. If you select one of the stars and select Edit ‣ XML Editor, you can then click on the "style" entry on the right to see its content in the panel at the bottom. You'll see that there are separate values for the "fill" property and the "opacity" property:

XML_dialog.jpg
XML_dialog.jpg (118.06 KiB) Viewed 2041 times


You can see that the "ff" at the end of the RGBA value actually gets converted to a value of 1 for the opacity. The "000000" from the RGB values is left untouched, though. So if you just change your search term to "fill:#000000" (no "ff") and make sure you're at least searching in the "style" property, it should work:

search_dialog.png
search_dialog.png (42.22 KiB) Viewed 2041 times


BUT there's a caveat! Black is a potentially tricky thing to search for, as anything with the fill "unset" will also appear black. In that case there's no "fill" property in the style at all. Interestingly, however, the Select Same ‣ Colour approach will select objects that appear black, whether that's because they have a black fill set or because their fill is unset.

You may not find them much use, but I have written articles covering the notion of an unset fill and the XML Editor dialog in parts 30 and 31 of my FCM series respectively: viewtopic.php?f=6&t=11981


Finally, please note that the page you linked to about the Find/Replace dialog is a specification that predates the real implementation. It describes a lot of "nice to have" features which never made it into the real thing. Don't read it as a list of things that the current dialog can do by any stretch of the imagination. Some of the things you've listed may be possible; others may be achievable in conjunction with other steps; others may not be possible purely within Inkscape at all. Rather than try to address each of them, I suggest that if you have a particular requirement you post it - otherwise people will end up spending their free time trying to find ways to achieve the specific things you've listed even though there's not really a need to do so.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

JuliaFlowers2
Posts: 40
Joined: Tue Jul 31, 2018 4:47 am

Re: Search & Replace

Postby JuliaFlowers2 » Thu Aug 09, 2018 6:19 pm

Thank you Xav, for taking the time to write that all down for me !

So it was the ff, that prevented it fro working...
I know i could have used the Select Same functionality but i really want to learn how to use the Find & Replace dialogue.

Also my question about the names for other object types remains unanswered.
When i look at the XML editor for ellipses it says path, but that seems a very general term, because all items with nodes are paths, right ?
Oddly enough, rectangles are called rect.




If the examples from the wiki page arent real working examples, what else could we use F & R for ?
The text example works. I was able to find a specific font and replace it with another one. So thats good to know.

What about "find all ellipses with given flat fill color and randomize that fill color between a given range of RGB/HSV/CMYK values" ?
That sounds like another solution to my recoloring problem from my first post.

Is this possible ? How do i define a fill colour range in RGB values in the replace dialogue ?

User avatar
Xav
Posts: 1209
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: Search & Replace

Postby Xav » Thu Aug 09, 2018 7:11 pm

The best way to think of the Find/Replace dialog is that it's the same as you might find in a simple text editor, and all it's really doing is searching through the XML text, just with a small amount of extra knowledge about the structure of an XML file.

To search for other object types you should use the checkboxes in the "Object Types" section at the bottom. Inkscape supports more basic types than SVG itself does, so for things like stars and spirals they're stored in the file as SVG <path> elements, but with extra metadata that Inkscape can use to treat them as other types - principally the "sodipodi:type" attribute. So to find all the stars, for example, you would unset the "All types" checkbox, and tick the "Stars" one instead. But you could also search for "star" in the attribute values of all types (do an exact match to avoid "start" in many style properties).

In my testing ellipses are stored in the SVG as <ellipse> elements. If you're seeing a <path>, then it's likely that your ellipse has been converted to a path via Path ‣ Object to Path. Just because it looks like an ellipse, it doesn't necessarily mean that it's still an ellipse primitive.


If the examples from the wiki page arent real working examples, what else could we use F & R for ?


As I said, ignore that wiki page. It was a spec, a planning document, a proposal. It has little to do with the implementation, or capabilities, of the dialog as it is currently implemented.

In my experience the "Find" part of the dialog is very occasionally useful, the replace part less so. Because it just acts like a text editor find & replace, if you don't have a good grasp of XML and how it is serialised to text you can easily make a replacement that will fundamentally break your file. As the "fill:#000000ff" example shows, you also need a good understanding of SVG and how things in the Inkscape UI map to the SVG file format to make the most of the advanced options.

In my opinion find and replace for anything other than simple string replacements is usually more hassle than it's worth for most users.


What about "find all ellipses with given flat fill color and randomize that fill color between a given range of RGB/HSV/CMYK values" ?


You should now be able to see that finding all true ellipses (those that haven't been converted to paths) with a flat colour is definitely possible. But the "replace" part of the dialog has no facility for taking anything other than plain text values - certainly no way to set a random fill colour. All you could really do is select them with the Fill dialog, then use the Tweak tool :tool_tweak: to jitter their colours, or use Extensions ‣ Colour ‣ Randomize. Neither of those approaches is likely to give you the fine-grained control it sounds like you want over the target colours - in which case the only option is to either create your own extension or modify the file outside of Inkscape (which, strictly speaking, is also what an extension does).
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter


Return to “General Discussions”