gotcha

Author Topic: Why does the origin of a line change when its width is changed?  (Read 434 times)

March 23, 2019, 09:47:26 PM
Read 434 times

vanepp

  • Sr. Newbie

  • Offline
  • **

  • 5
Given a line generated by this xml in an svg (copied in to a new svg)

    <line
       style="fill:none;stroke:#555555;stroke-width:0.62384444;stroke-linecap:round"
       y1="274.1402"
       y2="274.1402"
       x1="93.663437"
       x2="79.056557"
       id="connector6pin" />

The tool bar (set in inches) shows

x 3.100 y 0.600 w 0.600 h 0.025

change w from 0.6 to 0.105

with  edit->preferences->Behavior->transforms Scale stroke width unticked (because I know that will affect the stroke-width and perhaps other things)

what I expected:

x 3.100 y 0.600 w 0.105 h 0.025

what I get

x 3.090 y 0.888 w 0.126 h 0.025

If I repeat setting the x y and w several times it will converge on the requested values but I would rather it work sensibly i.e. a change of a single parameter changes only that parameter. Is there some setting that I'm missing that will do that?

Peter
  • 0.92.4
  • Win 7 Pro 64 bit

March 24, 2019, 04:25:15 AM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

I don't understand the XML code which you shared.  But you probably want to switch from visual bounding box to geometric bounding box.  Inkscape Preferences > Tools

Honestly, sometimes I wonder why developers don't make the geometric bounding box the default.  But I guess we'd get complaints the other way as well, if they did.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

March 24, 2019, 08:10:16 AM
Reply #2

vanepp

  • Sr. Newbie

  • Offline
  • **

  • 5
Thank you for the quick reply! I'm used to the Fritzing forum which has trouble with svg files, so this time I'll see if I can figure out how to include the svgs themselves (looks like I can!) first the original:

drawing-geometrical-bb.svg
*drawing-geometrical-bb.svg
(1.86 kB . 210x297)
(viewed 75 times)


This is created with the installation default preferences file with edit->preferences->Behavior->transforms Scale stroke width unticked. It is just a standard line with rounded end caps which is too long at 0.6 in when I want it to be 0.105in. So the default
visual bounding box with width changed from 0.6 to 0.105 produces this:

drawing-geometrical-bb.svg
*drawing-geometrical-bb.svg
(1.86 kB . 210x297)
(viewed 75 times)


Changing the x and width coords back to their desired values 3 times eventually creates the desired svg (this is my normal, if annoying procedure):

drawing-geometrical-bb.svg
*drawing-geometrical-bb.svg
(1.86 kB . 210x297)
(viewed 75 times)


Starting with the original file again and resetting preferences to installation again (because it reacts more oddly if I don't) unticking change stroke width again and changing preferences->tools from visual bounding box to geometric bounding box as suggested still doesn't entirely work. It changes the height to 0 (presumably because height is being supplied by stroke-width) which I could live with, as the visual representation is still correct, but the Y coord changes to 0.612 from 0.600 which is still incorrect as the final SVG is intended as an engineering drawing with exact coordinates.

drawing-geometrical-bb.svg
*drawing-geometrical-bb.svg
(1.86 kB . 210x297)
(viewed 75 times)


Hopefully the svgs attached correctly, all the instances look identical in here but should be 4 different svgs I hope.

Peter

  • 0.92.4
  • Win 7 Pro 64 bit

March 24, 2019, 11:07:12 AM
Reply #3

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Hhmm, I'm not sure if what you meant to be attached was actually attached.  If you saved the drawing-geometrical-bb.svg file after each change, before you attached it, that should work.  But these files all appear to be identical to me.  Possibly you didn't save in between changes?

In every case, the Line object is 0.105 inches long, and placed at x = 3.1, y = 0.612  (and all with geometric bb)

I notice that Inkscape identifies the object as a Line.  As far as I know, Inkscape can't produce that kind of object.  Did you perhaps paste it in from somewhere else?  Or maybe you coded the XML yourself?

However, I don't think that would have any effect on the problem you're describing.  Although I'm not entirely sure if I understand your problem correctly.  I'm pretty sure what you're describing, and the bounding box change should fix it.  But I'm not 100% that I understand your problem.

Inkscape will never show the height of a horizontal path (or line) as anything but zero.  At least not with geometrical bounding box.  It will show the height using visual bb.  Note that you have to deselect and reselect after changing the setting, to see it change.

There is one other problem with your file.  It wouldn't be causing this problem either, but you'll want to fix it.  You have the Scale set wrong, relative to the units.  Here's how to fix. 

1 - Document Properties > Page tab > Display Units (top of the page) Set to px
2 - Document Properties > Page tab > Scale (about halfway down the page) Set to 1.0
3 - Go back up to Display Units, and set whatever units you want, and never touch the Scale setting again, unless you're sure you know what you're doing

If you're using Inkscape for engineering, you'll definitely want to stick with the geometric bounding box.  Or else not use any strokes in the drawing.

Do you want to try and attach the files again?

  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

March 24, 2019, 02:21:32 PM
Reply #4

vanepp

  • Sr. Newbie

  • Offline
  • **

  • 5
Hhmm, I'm not sure if what you meant to be attached was actually attached.  If you saved the drawing-geometrical-bb.svg file after each change, before you attached it, that should work.  But these files all appear to be identical to me.  Possibly you didn't save in between changes?

You must be correct because they should be 4 different files and are not. I'll try and figure out how to save them between uploads although its not clear how to do that. Ah! I just found a more attachments button, which I missed the first time. So hopefully this will upload the three missing files.


 
I notice that Inkscape identifies the object as a Line.  As far as I know, Inkscape can't produce that kind of object.  Did you perhaps paste it in from somewhere else?  Or maybe you coded the XML yourself?

Yes it is a copy from a Fritzing part svg, the line portion of it is likely from Illustrator, but Inkscape seems perfectly happy with them (and I now know why it creates paths when I want a line :-)  .)


However, I don't think that would have any effect on the problem you're describing.  Although I'm not entirely sure if I understand your problem correctly.  I'm pretty sure what you're describing, and the bounding box change should fix it.  But I'm not 100% that I understand your problem.

Ok I'll try again (it may be easier with all the svgs up now). I started with a line at

x 3.1in y 0.6in w 0.6 in H 0.025in (from stroke-width)

What I want as an end result is a line

x 3.1in y 0.6in w 0.105 in H 0.025in

as shown in drawing-desired.svg (which I got by changing the tool bar to what I want three times in a row which eventually converges on the correct coord).  That is with a visual bounding box. Then I reset preferences, reloaded the original svg and unticked scale stroke-width and changed from visual bounding box to geometric bounding box in preferences->tools. Ah! just found my error. The change to geometric bounding box from visual alters the coordinates but only after you unselect and reselect the line (on experimentation). On reselect of the line the coords are x 3.112 y 0.612 w 0.575 h 0.0. If I now change them back to x 3.1 y .6 w.6 h0 and then change the width to 0.105 it works as expected. Thank you! With that in hand I can perhaps suggest some different Inkscape settings for Fritzing.



There is one other problem with your file.  It wouldn't be causing this problem either, but you'll want to fix it.  You have the Scale set wrong, relative to the units.  Here's how to fix. 

I'm actually very familiar with my friend scale (one of the best enhancements from 0.91). Sometimes Fritzing parts are in old Illustrator (72 dpi) and dimensioned in px which causes scaling problems. Setting the display units to pt and recording the start coordinates from the tool bar lets me rescale the drawiing to the 10.41667 scale Fritzing prefers. I though the settings I was using were default install, but I see they are not, I changed grids before saving that preferences file, I may have screwed up scale while doing that. Again thanks for your help!

Peter
  • 0.92.4
  • Win 7 Pro 64 bit

March 24, 2019, 06:22:58 PM
Reply #5

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Always like to hear good news!  I'm glad you found the problem, and everything working properly now.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann