Inkscape.org
Beginners' Questions Cut path and then delete lines not covered by cutting path
  1. #1
    jgk jgk @jgk

    I'm trying to create vector graphics for use with a pen plotter / cutting machine. One idea I had was to draw squiggly lines with a pen, but only where it overlaps text. My problem is how to automate this, because it's quite tedious to do manually. My approach is the following. I first have an open path and some text above it. I duplicate the text because one will be destroyed by the path operation.

    ย 

    Then I select open path and one text and do "Path / Cut Path". I can then only manually use the remaining text to select all the cut lines that are outside of it. This is the annoying, manual labor that I'd like to avoid. The end result is this (I've hidden the yellow T):

    Is there some automatic way to do this? Maybe a "select paths within path" command or extension, that determines for each section whether it's inside a path? For this example, manual mode is still workable but imagine this with more complicated patterns and texts, it gets too complicated quickly.

    Thanks for your help!

  2. #2
    Polygon Polygon @Polygonโš–๐ŸŒถ

    Will Object->Clip->Set Clip work with the plotter?

  3. #3
    jgk jgk @jgk

    No, clip paths sadly don't work as the plotter's software just ignores those. That's how I'd normally do this as well.

  4. #4
    Polygon Polygon @Polygonโš–๐ŸŒถ

    And converting the swirl into a pattern to fill the "T". Can the plotter work with that?

  5. #5
    jgk jgk @jgk

    No, it has to be simple standalone paths, so it knows where to start and stop cutting / drawing. The plotter's software is really not very sophisticated in that way

  6. #6
    Polygon Polygon @Polygonโš–๐ŸŒถ

    Ok - understood. Hereยดs the catch: Go the clipping path route and make a Bitmap copy (Edit menu) - select the result and go Path->Trace Bitmap->Single Scan=Centerline tracing.ย 

  7. #7
    David248 David248 @David248

    (method derived from a recent YT video from Sweater Cat Designs)

    • Turn letter to path, give a red stroke, no fill.
    • Select all, do path > fracture
    • Select one red path, make a right clic > select same > stroke color
    • (optional) do path > Combine
    • Do edit > Invert Selection : delete black paths
  8. #8
    Polygon Polygon @Polygonโš–๐ŸŒถ

    @David248 Put the letter underneath the swirly path - select both and go Path->Division - kill fill color - adjust Stroke color and width. Same result.

  9. #9
    jgk jgk @jgk

    The division method is not really the same result, as each tile shares borders with its neighbors. And these borders would all be followed twice by the plotter.

  10. #10
    Polygon Polygon @Polygonโš–๐ŸŒถ

    Thatยดs why I didnยดt have this approach on the agenda. Howยดs with #6?

  11. #11
    jgk jgk @jgk
    ๐Ÿ‘

    The bitmap method works in principle, it just doesn't quite recover the correct paths. Might not matter for plotting so a good workaround to have. I'm currently trying my hand at writing a simple extension to remove the paths that remain after "cut path".

  12. #12
    Polygon Polygon @Polygonโš–๐ŸŒถ
    jgk

    I'm currently trying my hand at writing a simple extension to remove the paths that remain after "cut path".

    I wonder why this isnยดt implemented as it absolutely makes sense.

  13. #13
    Paddy_CAD Paddy_CAD @Paddy_CAD
    ๐Ÿ‘

    Try this extension.

    https://github.com/funnypolynomial/DestructiveClip

    ย 

  14. #14
    David248 David248 @David248
    *

    @Paddy_CAD :ย  I failed to install this extension with inkscpae 1.3 (released in july 2023).

    .inx file seems to have been updated for compatibily in march 2023 in github

    ย I copy-pasted both .inx and .py in extension folder, but, once inkscape restarted, can't find it in Extensions > Modify Path menu

    ย 

    Edit : fixed

  15. #15
    Paddy_CAD Paddy_CAD @Paddy_CAD

    I'm running Inkscape 1.3 on MacOS. I installed the extension yesterday and it seems to work perfectly.ย I have no idea why it doesn't appear in your extensions menu. Have you installed other extensions successfully?

  16. #16
    jgk jgk @jgk
    ๐Ÿ†’*

    For a second I thought that extension was the real deal! Sadly, it only works with beziers flattened to line segments. While that's still cool, and for a plotter it doesn't matter that much I think (it probably converts to lines internally anyway before computing the control pattern) I never like to prematurely throw away data. I can't edit the result as well as I could with the original curves if I later need to make some adjustments.

    My experiments with an extension are already not looking too bad, although I'm still having problems with computing bezier intersections correctly. Will need some more fiddling and learning about inkscape's data structures.

  17. #17
    David248 David248 @David248

    @Paddy_CAD : other installed extensions work well ๐Ÿ˜ถ

  18. #18
    Tyler Durden Tyler Durden @TylerDurdenโš–

    There is also the Alt+LMB drag to quickly select.ย 

    ย 

  19. #19
    David248 David248 @David248

    You can also use fracture / division then Remove Duplicate Lines Extension, a handy extension for plotter users.

  20. #20
    jgk jgk @jgk
    ๐Ÿ†๐Ÿ†๐Ÿ†*

    The proof of concept of my extension seems to work :)

    It loops through the paths, of which we know that they are either completely inside or outside the cutting path. So we have to just check a single point on each for being inside / outside. This is done by doing a line intersection against each segment of the cutter path and counting the intersection points. Even is outside, odd is inside. I delete all outside paths and concatenate the rest. It seems to work with paths that only have curves, but not with my initial example, the letter "T". I'm probably still doing something wrong with the `CubicSuperPath` and conversions.

    Edit: Actually a T shape also works, it's just that text sets a `transform` so the path coordinates I was reading were the untransformed ones so it didn't work.

    ย 

  21. #21
    jgk jgk @jgk
    ๐Ÿ†’๐Ÿ†

    Now I've got the extension in a pretty convenient state, it does the path conversion, cutting and other bookkeeping automatically. Might upload that somewhere at some point so it's useful for others. I did have to implement a custom bezier line intersection algorithm because the inkex-supplied one seemed to be buggy. It would sometimes get intersections in places way off the line, pretty weird.

    ย 

  22. #22
    Tyler Durden Tyler Durden @TylerDurdenโš–

    This looks very useful.

    If you would like to share it, please add it to the Inkscape Gallery. There is a button in the upper-right corner of your user profile.

    Some members post a screenshot with links to a GitLab page where the code is hosted. Example:ย https://inkscape.org/~Moini/%E2%98%85multiple-boolean-operations-with-inx-pathops

    ย 

    ย 

    ย 

  23. #23
    David248 David248 @David248

    Looks very promising ! It would be very kind of you to share it.

  24. #24
    jgk jgk @jgk
    ๐Ÿ†๐Ÿ†

    I've done that here, hope it helps https://inkscape.org/~jgk/%E2%98%85cut-and-remove-by-shape-extension

  25. #25
    Polygon Polygon @Polygonโš–๐ŸŒถ

    A stroke of genius. Thanks for sharing.

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Cut path and then delete lines not covered by cutting path