Select objects with similar size

Post questions on how to use or achieve an effect in Inkscape.
User avatar
hellocatfood
Posts: 193
Joined: Fri Aug 29, 2008 8:49 pm
Contact:

Select objects with similar size

Postby hellocatfood » Fri May 03, 2019 10:39 pm

Is there any way to select objects based on their size? I know that there are already functions for selecting objects with the same colour and stroke, but I have a document with lots of small objects that I'd like to remove.

Document attached.
Attachments
linedrawing.zip
(35.04 KiB) Downloaded 131 times
I'm on The Web | Flickr | tumblr

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Select objects with similar size

Postby Moini » Fri May 03, 2019 11:50 pm

I don't know about removal, but you can join the nodes that overlap, to get real curves, instead of many disconnected lines.

https://github.com/fablabnbg/inkscape-chain-paths

I thought there also was an extension that deletes short paths, with a settable path length, but I cannot find it now. Can anyone else, or does anyone remember where it lives?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

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

Re: Select objects with similar size

Postby brynn » Sat May 04, 2019 1:49 am

I remember a couple of users asking about an extension to remove objects based on size (in the last couple of years), but I don't remember seeing one.

Hhmm, I don't seem to have one in my master list, although I could have missed adding it to the list.

User avatar
hellocatfood
Posts: 193
Joined: Fri Aug 29, 2008 8:49 pm
Contact:

Re: Select objects with similar size

Postby hellocatfood » Sat May 04, 2019 2:38 am

Moini wrote:I don't know about removal, but you can join the nodes that overlap, to get real curves, instead of many disconnected lines.

Thanks! That extension looks like it'll be very useful, especially as I plan to use a plotter to draw these images.

brynn wrote:I remember a couple of users asking about an extension to remove objects based on size (in the last couple of years), but I don't remember seeing one.

Hhmm, I don't seem to have one in my master list, although I could have missed adding it to the list.

Maybe something to add to the bug tracker? Seems like it could be useful, especially for people who trace bitmaps a lot.
I'm on The Web | Flickr | tumblr

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

Re: Select objects with similar size

Postby brynn » Sun May 05, 2019 1:51 am

I've never heard of putting specifically extension requests in the bug tracker. But it could be added just as a general feature request. Who knows, maybe some developer would want to make it a native feature?

Here's the new bug tracker: https://gitlab.com/inkscape/inbox/issues

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Select objects with similar size

Postby druban » Sun May 05, 2019 2:46 pm

This is a completely useless idea. You have been warned.
You can select and delete all objects below a certain size by selecting everything and aligning their right or left edges with the left or right edge of the page or any target (or top and bottom or even center etc). Then by making your selection marquee narrow enough you can only enclose those objects that are small enough to fit inside it, and then delete them.

Of course this leaves your document completely wrecked so that's why it's useless.

A similar method would clone everything, drag the clones away from the drawing and align them to an edge as above. Marquee select all the small clones as above and drag them away to separate them from big clones which you can then delete. Now click on a small clone, Shift D to find the original, then delete it, delete the clone, and do the next one. This method is only slightly less useless than the first but makes up for it by being very slow. Sadly Inkscape will not perform Shift D 'Look up original' if more than one clone is selected.
Your mind is what you think it is.

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

Re: Select objects with similar size

Postby Lazur » Sun May 05, 2019 7:48 pm

Hi.

For this specific project you may find a solution besides the previous requests where each path would take some analysation on their sizes.
The small paths seems to be paths with 0 length. In the xml they look like "m 609,210 0,0" -that 0,0 is probably good enough to spot them all.
At least now with notepad++ you can mark them all.
Search for >>v 0"<< in your file and you'll find 1380 matches.

Other idea is importing it to blender, joining objects, converting to a mesh, select all nodes, then remove doubles.
Sadly this will also result in one compound path in the process and may remove other details -if you manage to transfer the result from blender to inkscape. (For example by exporting to an obj file and using the render 3D polyhedron extension in inkscape.)

Edit:
That notepad++ method seems to work.

Open svg in notepad++
Find (Ctrl+F), choose the mark tab and type in >>v 0"<< in the spinbox; Find All
then
Search/Bookmark/Cut bookmarked Lines and
save as svg.

Open that svg in inkscape,
select all (Ctrl+A) and paste it in place (Ctrl+Alt+V) in another document so you won't have the garbage in your file from those brute-forcedly deleted path code segments.

Upon testing your 1646 objects became reduced to 265.



Although you'd still have alot of unwanted clipping and cloning going on and a weird page size.
Attaching a cleaned up version.
linedrawingx4.svg
(85.34 KiB) Downloaded 124 times

User avatar
hellocatfood
Posts: 193
Joined: Fri Aug 29, 2008 8:49 pm
Contact:

Re: Select objects with similar size

Postby hellocatfood » Sun May 05, 2019 10:44 pm

brynn wrote:I've never heard of putting specifically extension requests in the bug tracker. But it could be added just as a general feature request. Who knows, maybe some developer would want to make it a native feature?

Here's the new bug tracker: https://gitlab.com/inkscape/inbox/issues

Thanks, I'll definitely request it. I'll probably reference this topic as I think it makes a good case for why it would be a good idea.

Lazur wrote:Hi.

For this specific project you may find a solution besides the previous requests where each path would take some analysation on their sizes.
The small paths seems to be paths with 0 length. In the xml they look like "m 609,210 0,0" -that 0,0 is probably good enough to spot them all.
At least now with notepad++ you can mark them all.
Search for >>v 0"<< in your file and you'll find 1380 matches.

That's what I ended up doing but you're right that a more general feature would be more useful in the future and for more people.
I'm on The Web | Flickr | tumblr

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Select objects with similar size

Postby druban » Mon May 06, 2019 7:13 am

I'm sorry I did not see that you had attached a file in your original post!
All you had to do really is use the Find and replace dialog (Ctrl F) and type in ' v 0' and search in properties (the default is usually text). 1380 objects are found and selected, just hit delete. 266 objects left. You don't have to do this outside Inkscape. Afterwards do 'clean up document' to get rid of 1440!! unused definitions...

It looks like the svg was created by converting from some kind of data? If you are trying to make it more presentable I have combined the multiple path on the right into one path and used a gradient to paint it, if you think that looks better... That also cleaned up another 150 defs, making the file smaller, which might be a goal: so far a 1MB file has become a 129KB file, I estimate you can get it down to 90KB.
Attachments
linedrawing2.svg
(129.21 KiB) Downloaded 120 times
Your mind is what you think it is.

User avatar
hellocatfood
Posts: 193
Joined: Fri Aug 29, 2008 8:49 pm
Contact:

Re: Select objects with similar size

Postby hellocatfood » Mon May 06, 2019 7:30 am

I added a feature request here https://gitlab.com/inkscape/inbox/issues/449
I'm on The Web | Flickr | tumblr

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

Re: Select objects with similar size

Postby Lazur » Mon May 06, 2019 4:12 pm

druban wrote:All you had to do really is use the Find and replace dialog (Ctrl F) and type in ' v 0' and search in properties (the default is usually text).

Nice found!

druban wrote:That also cleaned up another 150 defs, making the file smaller, which might be a goal: so far a 1MB file has become a 129KB file, I estimate you can get it down to 90KB.


And a little more.
cln.png
cln.png (5.95 KiB) Viewed 2550 times


I suspect it can still be compressed way more. Like, by not using the most possible digits to store coordinates and definitely by combining the paths, merging double nodes and one gradient only etc. 10-20 KB I'd estimate.

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Select objects with similar size

Postby druban » Mon May 06, 2019 5:51 pm

How about that legacy file warning, haven't seen that for a while.
Mostly I was suggesting by my example the combining of the paths (which are in little pieces in order to perhaps simulate a gradient with many flat colors) and then using an actual gradient.
Saving as non inkscape svg and reducing precision is more than I was suggesting but of course would bring size down. In my experience no one really cares these days about several thousand bytes here and there...
Your mind is what you think it is.

User avatar
hellocatfood
Posts: 193
Joined: Fri Aug 29, 2008 8:49 pm
Contact:

Re: Select objects with similar size

Postby hellocatfood » Mon May 06, 2019 8:38 pm

The SVG was created in Processing with a modified version of the following sketch https://www.openprocessing.org/sketch/694218

It's PDF and SVG export libraries probably do need some work.

Mostly I was suggesting by my example the combining of the paths (which are in little pieces in order to perhaps simulate a gradient with many flat colors) and then using an actual gradient.

If you look at the sketch then you'll see that in order to simulate a gradient along a path, at major turns in the path it just draws a straight line and changes colour. Replacing this with one gradient wouldn't work as the path turns back on itself many times.
I'm on The Web | Flickr | tumblr

User avatar
hellocatfood
Posts: 193
Joined: Fri Aug 29, 2008 8:49 pm
Contact:

Re: Select objects with similar size

Postby hellocatfood » Tue May 07, 2019 10:43 pm

hellocatfood wrote:I added a feature request here https://gitlab.com/inkscape/inbox/issues/449


I updated the feature request with an idea for fuzzy selection for selecting objects with same size which could also extend to the Select Same Fill Colour option. Take a look and add your thoughts!
I'm on The Web | Flickr | tumblr


Return to “Help with using Inkscape”