Snap object to path

Post questions on how to use or achieve an effect in Inkscape.
rinbad
Posts: 31
Joined: Sat Apr 19, 2014 6:48 pm

Snap object to path

Postby rinbad » Sat May 24, 2014 12:08 am

Apologies if this seems a daft question, but it's one to which I haven't been able to find an answer anywhere. I'm working on a simple map of railways, with a plain background and coloured lines to represent the lines-of-route. To indicate stations I'm using small circular objects all cloned from one original. As I place each of those station-markers I'd like to be able to snap it to the path of the line-of-route so that the centre of the marker lies accurately on the path itself. But I can't find any way to achieve that and so have to centre each station-marker by hand (and then if in the course of adjustment the line moves slightly, the object is once again off centre). Am I missing the blindingly obvious somewhere?

And an associated question. I'd like to be able to use a different marker (a thin rectangular or small square object) at the junctions between lines. I can again get consistency of markers by cloning. Again it would be good to be able to snap it to the path of the line-of-route so that it extends equally on either side, but this time with the further complication that I'd like the symbol to be precisely at right-angles to the underlying path. Can this be achieved other than "long-windedly" by hand?

With many thanks in advance for pointing it out to me if there is a simple solution .... :? posting.php?mode=post&f=5#

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

Re: Snap object to path

Postby Lazur » Sat May 24, 2014 12:30 am

Hi.

The snap between bounding box centre and path segments doesn't seem to work.
How to hack a solution? Add a node to the centre of the circle path.
Maybe not the nicest solution, but it is effective.

hlp132.svg
(11.86 KiB) Downloaded 199 times



The second problem cannot be solved with more compromise.
If you use somekind of bend live path effect or pattern along path lpe, it may distort the marker object.
Other than that, you cannot be sure about the underlying path's tangent.
To make it precise manually I would add a new node to the path at the position in question,
run the visualize path draw handles extension, then could convert that path to guides (Shift+G),
double click the right tangent guide, and copy the rotaion value to the transformation panel (Shift+Ctrl+M)
and rotate the marker object.
Not so efficient with a larger number of objects.

rinbad
Posts: 31
Joined: Sat Apr 19, 2014 6:48 pm

Re: Snap object to path

Postby rinbad » Sat May 24, 2014 7:16 pm

Thank you. I hd tried the snap between bounding box centre and path, found that it consistently didn't seem to work, and assumed that I was doing something wrong. (Incidentally, I can't get re-link clones to selection to work either.) I'll certainly use your suggested hack in new work as it's very easy to put the additional nodes in whilst tracing the lines from an underlying source.

As you comment for the second question, not so efficient for a larger number of objects. I think what I'll have to do there is use another circular marker of some sort, as that seems so much easier to deal with. It would be nice to use a short line, but as it looks daft if it isn't at right-angles and as that can't readily be achieved, then best avoided.

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

Re: Snap object to path

Postby Lazur » Sat May 24, 2014 7:41 pm

Just another idea with that first solution.
It seems as the centre node is rendered if viewed with a browser, so maybe you should group a smaller filled circle atop the basic marker to make it "bullet proof".

You cannot re-link clones, but you can select objects with the same attributes at once and change them together, which may help.
To do that, select one marker object, press Shift+Ctrl+X to open the xml editor, copy the stroke attribute/stroke width attribute, then
open the search panel (Ctrl+F), and paste the values into the style field and run search.

rinbad
Posts: 31
Joined: Sat Apr 19, 2014 6:48 pm

Re: Snap object to path

Postby rinbad » Sun May 25, 2014 9:53 pm

Thanks -- I'll have a go at that.

With clones I was referring -- inaccurately from memory -- to the command "Relink to Copied" as described in the Manual (Tavmjong Bah, 4th edition), page 138. That was what I couldn't get to work. Thanks for the advice on making changes via the xml editor. I've fought rather shy of that so far, but will have to make an effort to get to know it!

dvlierop
Posts: 139
Joined: Sat Sep 08, 2007 4:25 am

Re: Snap object to path

Postby dvlierop » Thu Jun 05, 2014 6:13 am

Please note that you cannot snap bounding boxes to paths/nodes, and vice versa. This is also why they're in separate groups on the snap toolbar.

The underlying reason for this is that when using a visual bounding box, the bounding box encompasses the stroke width, and therefore the corners are off the center-line of the paths and at the edge of the stroke. Snapping the bounding box corners to a path or to nodes (which are at the center of the stroke), would therefore not give a perfect alignment, so by design it doesn't snap at all in this case.

What you could do is snap the item's center or rotation center to the path, For this you'd use the 5th and 6th button from the end of the snap toolbar.


Return to “Help with using Inkscape”