How to delete objects not entirely insided the document?

Post questions on how to use or achieve an effect in Inkscape.
toxigames
Posts: 149
Joined: Sat Aug 17, 2013 7:28 pm

How to delete objects not entirely insided the document?

Postby toxigames » Fri May 12, 2017 11:34 pm

I wish to auto-delete objects that are not entirely within the document. I am using the spray tool to quickly paint a starry universe background. A bunch of stars will then be located outside the document, and some will become placed cross the document border. I only want to keep the stars that are entirely within the document borders.

I guess another function that could solve this is if you could easily select all objects within the document borders. I have tried to drag the select tool lines from the left bottom corner up to the right top corner, but unfortunately it's too difficult to start precisely at position (0,0) and end exactly at position (document width, document height).

Is this possible?

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

Re: How to delete objects not entirely insided the document?

Postby brynn » Sat May 13, 2017 4:06 am

So you mean that some stars will actually be cut off, if they are lying across the border, partly in and partly outside the border?

If that's the case, you can must a multiple path operation (boolean). I would probably use Multiple Division. I'm not sure if it's installed in the current stable version. I know I installed it earlier. But you can find it on the Inkscape website. Go to the gallery, and click on the Extensions filter. And there you will find it. Here are instructions to install, if you need it: https://inkscape.org/en/learn/faq/#how- ... n-sets-etc

To use it, first you need a rectangle the exact same size as your page. If you set up snapping so that you snap to the page, you can draw any size of rectangle, and then use the scaling arrows to drag it to the right size. If you have snapping set up properly, the rectangle will snap right to the corners. Or you can use the W and H fields on the Selection control bar, to set the rectangle size (dimensions). And then use the X and Y fields to align it to 0,0.

After you have the rectangle, select all the stars and the rectangle. Make sure the rectangle is on top of all the stars, then Extensions menu > Boolean > Multiple Division. It will look like nothing happened, but don't worry, it did. Click on one of the stars the lies on the page border, and you will see that it is now in 2 parts. So you can go around the border and delete the outer parts of those stars.

Clipping will do something similar, except the stars won't be cut off at the border. They'll more or less be just hidden, but they're still part of the file.

toxigames
Posts: 149
Joined: Sat Aug 17, 2013 7:28 pm

Re: How to delete objects not entirely insided the document?

Postby toxigames » Sat May 13, 2017 4:43 am

brynn, thank you for answering :). Clipping will cut off the stars that crosses the border though, that's what clipping does if I were to say use a rectangle with the same dimensions as the document to clip the stars. The stars must not be cut off, as mentioned in my OP "auto-delete objects that are not entirely within the document". So any stars that are either crossing the document edge or are outside the document edge must be deleted. Only stars that are entirely inside and within the document borders must be preserved. Cutting stars in two pieces on the edge wont do, those have to be deleted also.

I can already go around the border selecting and deleting any stars that are outside/crossing the border. But it's a bit tedious to manually inspect the border all around, especially when its a large document of for example 1024x1024. But I guess that's how it'll have to be for now unless there is a way to accomplish it automatically.

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to delete objects not entirely insided the document?

Postby theozh » Sat May 13, 2017 5:44 am

The following might be a feasible solution:
Since I don't know what other objects you have on the page it might be helpful if you draw the stars in a separate layer.
1. draw a rectangle including all stars
2. draw a rectangle with the exact size of the page (use snapping to page border)
3. do a boolan difference to get the cyan frame (Ctrl+-)
4. select all stars and the cyan frame, do Path unify (Ctrl++)
5. break the new path apart (Shift+Ctrl+K)
6. delete the two unnecessary subpaths
Your desired full stars are left over. Hope it works for you...


OnlyFullStars.png
OnlyFullStars.png (7.24 KiB) Viewed 1981 times
Win7/64, Inkscape 0.92.2

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

Re: How to delete objects not entirely insided the document?

Postby Moini » Sat May 13, 2017 7:00 am

How about using the spray tool to create the stars in the first place? It has options to only spray on specific background (e.g. 'not on transparent areas'). You could make the background opaque, and use that option to your advantage.
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)

toxigames
Posts: 149
Joined: Sat Aug 17, 2013 7:28 pm

Re: How to delete objects not entirely insided the document?

Postby toxigames » Sat May 13, 2017 7:51 am

Moini wrote:How about using the spray tool to create the stars in the first place? It has options to only spray on specific background (e.g. 'not on transparent areas'). You could make the background opaque, and use that option to your advantage.


I am indeed already using the spray tool as mentioned in OP :) this is actually the reason I have this problem in the first place, because some of the stars are sprayed out side the document area or end up right on the border. Because I am spraying hundreds of tiny stars, it's not as easy to remove those stars manually as one might think (maybe I should have included a picture to begin with!, but here it is anyway :) ).

However I was not aware of specifying to not spray on transparent areas; but I see that option now. So I just tried it, but even with this option there will unfortunately still be objects sprayed over the border of the document. So while no objects will be sprayed outside of the document, there will still be objects being placed over the the edge and parts of those objects thus will be touching transparent areas; as seen on screenshot below.


Image


Image

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

Re: How to delete objects not entirely insided the document?

Postby Moini » Sat May 13, 2017 8:15 am

Then also check the 'no overlap between colors' option and you're done ;-) (you may need to set a temporary uni-colored background rectangle)
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)

toxigames
Posts: 149
Joined: Sat Aug 17, 2013 7:28 pm

Re: How to delete objects not entirely insided the document?

Postby toxigames » Sun May 14, 2017 4:17 am

Moini wrote:Then also check the 'no overlap between colors' option and you're done ;-) (you may need to set a temporary uni-colored background rectangle)


Thank you Moini! That works perfectly :D

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

Re: How to delete objects not entirely insided the document?

Postby Moini » Sun May 14, 2017 4:56 am

I think we'd need to thank Jabier, for introducing that rich feature set to the spray tool :)
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)

toxigames
Posts: 149
Joined: Sat Aug 17, 2013 7:28 pm

Re: How to delete objects not entirely insided the document?

Postby toxigames » Sun May 14, 2017 7:32 pm

yes definitely, very useful it is.


Return to “Help with using Inkscape”