Best way to reselect multiple objects

Post questions on how to use or achieve an effect in Inkscape.
Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Best way to reselect multiple objects

Postby Vectorator » Wed Feb 25, 2015 11:31 pm

Is there a way to select a bunch of objects and give them all some sort of property that enables me to reselect them all again later? such as a collective name they all share.


I know I could give them all names one by one such as "apple 1", "apple 2", "apply 3" and then use search for apple but is there a quicker way?

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

Re: Best way to reselect multiple objects

Postby Lazur » Wed Feb 25, 2015 11:41 pm

There is the find tab (Shift+Ctrl+F) which ca help select objects of the same kind, like objects with same fill attribute or stroke width.
(Open the xml editor (Shift+Ctrl+X) to copy the right attribute.)

Also there is a feature in 0.91 of selecting similar objects (?).


To make things more organised, you can group objects together -and add attributes to the group itself, instead of to the objects inside-,
or use laers (Shift+Ctrl+L).

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: Best way to reselect multiple objects

Postby Vectorator » Wed Feb 25, 2015 11:48 pm

Thanks,

The search seems to only search in the ID field, not in label, title or description.

The ID field has to be unique so I cant use it as a group label easily (when I say group label I mean to apply one label property to lots of objects that may be in lots of different groups.)

It can be done with a few different methods as you point out, but I wish there was a simpler way.

User avatar
brynn
Posts: 10006
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Best way to reselect multiple objects

Postby brynn » Thu Feb 26, 2015 12:50 am

This, from 0.91 Release Notes, indicates some new features for Find dialog, although I have not investigated myself. It looks like you can search Properties, which I assume means Object Properties. http://wiki.inkscape.org/wiki/index.php ... d.2FSelect

One way I've used, if i need to reselect a multiple selection, it to have them all on a layer (and nothing else on that layer). Grouping, as Lazur suggested, is another way I've used.

Be sure to expand the new Options option, to show more possibilities.

Edit
There have been multiple requests for a way to reselect the last selection, or similar function, but it hasn't happened yet.

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

Re: Best way to reselect multiple objects

Postby Xav » Thu Feb 26, 2015 12:56 am

I have a rather sneaky suggestion that might help you (based on 0.48.x, but I suspect a similar approach would work in 0.91)...

In the Edit > Find dialog you can search for objects with a particular "attribute". So if you can ensure that all the objects have the same attribute, it's easy to select them. But how to ensure that?

If you right click on an object and select the Object Properties dialog there's a section at the bottom for Interactivity. The intention here is that programmer types can put in some Javascript that will run when the object is clicked or when the mouse moves over it, provided you're loading the SVG into a web browser. If you put a value into one of these fields then the SVG will acquire a similarly named attribute that contains the value. Remove the value and the attribute is also removed.

So for each object (you have to do them one at a time, unfortunately) you can put a value (e.g. "1") into the onclick field (or any of the others). No need to press the "Set" button for these fields. Then in the Find dialog you can search for all those objects that have an "onclick" attribute. It's not a perfect approach, but might work for you as a workaround.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

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

Re: Best way to reselect multiple objects

Postby tylerdurden » Thu Feb 26, 2015 1:05 am

Hahaha.. I was typing when Xav got in...

"Ok, here's a really ghetto method you can try, but I'm not sure it won't interfere with any other things you're playing with, particularly if you are using the svg in a browser.

Use at your own risk.

In the Interactivity panel of any object, you can add values to the fields for scripting like onLoad, onMousover, etc.

The Inkscape search can find those values.
"
Attachments
Find1.jpg
Find1.jpg (193.97 KiB) Viewed 3651 times
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/

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: Best way to reselect multiple objects

Postby Vectorator » Thu Feb 26, 2015 1:06 am

That suggestion in the last two posts, works very well, thanks. It's a good workaround.

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

Re: Best way to reselect multiple objects

Postby Xav » Thu Feb 26, 2015 2:13 am

Having now installed 0.91 here, I've got a potentially even better option:

1) Select your objects
2) Extensions > Stylesheet > Merge Styles into CSS
3) Supply a name for the class.
... some time later...
4) In the Find dialog, search your class name using "Properties" and "Attribute Value" settings.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

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

Re: Best way to reselect multiple objects

Postby tylerdurden » Thu Feb 26, 2015 2:36 am

Nice. :ugeek:
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/

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: Best way to reselect multiple objects

Postby Vectorator » Thu Feb 26, 2015 12:46 pm

Neat, that is the best solution yet. Works great, also works if you add objects.

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

Re: Best way to reselect multiple objects

Postby Xav » Fri Feb 27, 2015 3:42 am

And now for an even better solution...

I've used this as an opportunity to have a try at writing an Inkscape extension. Note that this is my first ever extension, and my first ever real-life Python code, so there's not a whole lot of error checking going on! I've attached the extension in a zip file - it just needs both files in there to be put into your Inkscape extensions directory, then launch Inkscape 0.91 and you should find it as Extensions > Stylesheet > Modify Class List...

Here's how to use it:

1) Select one or more objects
2) Launch the extension
3) Supply a space-separated list of class names. E.g. if you've selected all the big green circles you might want to use "big green circles" as class names. Equally you could just use "selection1" or whatever other name(s) you want.
4) Ensure it's in "Add Class List" mode and click the Apply button.

If you look at your objects using the XML editor they should each have been given a "class" attribute with the list of class names you specified. Now select some more/other objects - e.g. all the circles, regardless of size. Go through steps 1-4 to add a "circles" class to each of them. You should find that any objects that already had the "circles" class won't get it added a second time. Repeat for any other selections you want, giving them whatever class names you want.

Now to re-select a group of objects, just use the Find dialog to search for a class name that all the objects share. So in this example you can select all the circles by searching for "circles".


Other options:

* If you use "Remove Class List", any classes you list will be removed from the class attribute on each selected object. If doing this would leave an empty class attribute it will be removed if the "Remove Class attribute if it's empty?" box is checked.
* If you just want to remove the class attribute from every selected object, regardless of what's in it (i.e. to tidy up after yourself without having to remember all the class names you used), select the "Remove Attribute (dangerous!)" option. This will remove the attribute irrespective of what's in the Class List field.


Other uses:

As well as using this for searching purposes, it could also be useful to add classes for subsequent use with an external stylesheet, or with Javascript code (using document.querySelector() or document.querySelectorAll() ) when creating an SVG file for use in a web browser.
Attachments
modify-classlist.zip
Inkscape extension for modifying the "class" attribute of objects
(1.65 KiB) Downloaded 60 times
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

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

Re: Best way to reselect multiple objects

Postby tylerdurden » Fri Feb 27, 2015 5:14 am

That is soooooo nice!

But of course, we end-users always want more...
Would be great if the object(s) remain selected after the extension runs.
Would be great if a search tool had operators: and/or/not etc.
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/

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

Re: Best way to reselect multiple objects

Postby Xav » Fri Feb 27, 2015 8:30 am

tylerdurden wrote:Would be great if the object(s) remain selected after the extension runs.
Would be great if a search tool had operators: and/or/not etc.


As far as I can see Inkscape always de-selects the objects after an extension has been run, so I've got no control over that. Similarly I don't think it's possible for an extension to select objects, so there's no way for a more advanced search tool to be implemented as an extension.

You can sort of simulate AND/OR/NOT to a limited degree. AND is just a case of finding all the objects with one class name, then doing the same for the next class name but with "Search in selection" checked. NOT can be achieved to some extent by finding objects then using Edit > Invert Selection. OR is trickier, but you could do it by finding one set of objects and using my extension to give them an additional class name; then find another set and also give them the same name; then finally find that new name.

But really my extension is only there to serve two purposes: (1) so I could have a go at writing an extension (it was a painful experience!) and (2) as a solution to the question of how to "store" a particular selection for re-use later. Anything else it can be used for is a bonus.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

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

Re: Best way to reselect multiple objects

Postby tylerdurden » Fri Feb 27, 2015 9:07 am

Clever tips... Thank You!
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/

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: Best way to reselect multiple objects

Postby Vectorator » Wed Sep 13, 2017 6:02 pm

I've been using the method where you put a keyword in the object properties then use the "Find/Replace" dialogue on the right but I discovered something strange that might be a bug.

So if you choose some text in the design and you right click > Object properties then if you write anything in either the Title or Description and click set an interesting bug comes up. The next time you want to edit the text object on the page if you select all text and try to write something new you cannot type anything, only by leaving one letter there and retyping then deleting the one letter later can you write new text. As soon as you delete anything written in object properties "Title" or "Description" fields this strange bug stops. The solution seems to be to use only the Label field for custom keywords to select later.

Maybe someone can put this in an Inkscape bug report.

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

Re: Best way to reselect multiple objects

Postby Lazur » Wed Sep 13, 2017 6:18 pm

Since then, selection groups got implemented (in 0.92?).

Select all, create a new selection group, name it and add selected objects to selection groups.
It can one click reselect every object in a selection group regardless which layer is it on or any custom attributes.

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: Best way to reselect multiple objects

Postby Vectorator » Wed Sep 13, 2017 6:26 pm

A nifty new feature. Looks good. Thanks.

Oh but wait there is a small limitation of this new feature, one thing I wanted to do was that whenever I duplicate or copy an object I wanted it to automatically be part of the group, looks like this new method doesn't do that so if would have to be manually added.

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

Re: Best way to reselect multiple objects

Postby Lazur » Wed Sep 13, 2017 6:36 pm

"Still in development" I guess. Like there is a bug report on the cleanup document option removing selection sets from the svg too.


Return to “Help with using Inkscape”

Who is online

Users browsing this forum: No registered users and 5 guests