Author Topic: Unexpected scaling the shapes  (Read 2835 times)

September 06, 2017, 03:08:36 AM
Read 2835 times

Marek

  • Sr. Newbie

  • Offline
  • **

  • 2
Hi,

I have serious problem with strange behaviour of Inkscape. Document units: mm (not px - this is important). Lets create 2 overlapping rectangles and make union of them (Ctrl + +). The XML editor shows the result as roughly 4x bigger shape than originals and next scaled by magic number 0.26458333. The combination gives visually proper dimensions but not precisely.

The problem is with using such a strange result in CAM software (for CNC machines). Eg. if original width of equals 20mm and it will be expanded and then scaled down, the final result will have width eg 19.9964324 instead of original 20. This is different number for CAM software. Instead of 10 lines g-code for CNC machine I get 360!!!

Is it possible to merge 2 shapes without making them huge and scaled down? I would expect the result as simple path with dimensions as components without any distortion set in 'transform' attribute.

Attached files:
test.svg - example
p1.jpg - 2 rectangles copied and then merged
xml.jpg - properties of new shape having unexpected transform attribute
p2.jpg - the same result shape after when transform attribute was cleared
  • Inkscape version 0.92.2
  • Windows 10

September 06, 2017, 07:59:35 AM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

This sounds like a problem which the developers need to answer.  (Unfortunately, Inkscape developers rarely visit forums.)  And I'll give you the info for contacting them.

But first, I'm curious where you are seeing the size of an object in the XML Editor.  Are you actually calculating it from the nodes' placement shown in the d or path data attribute?  It sounds like you probably know a lot more about this that I do.  And if so, just say so, and move on to contact the developers. 

But I'm not sure if that is a proper comparison or confirmation.  Do you realize that those coordinates are relative to a 0,0 origin at the top, rather than at the bottom?  That's got to be a very difficult calculation!  (One of the next few new versions is planned to make the coordinate grids match.)

As for the transform attribute, in Inkscape Preferences > Behavior > Transforms, do you have set for Optimized or Preserved.  If Preserved, you might try setting for Optimized.

I'm thinking you must be set for Preserved.  Because I'm set for Optimized, and I don't see a transform attribute in the XML Editor.

Developers can be contacted via mailing list.  Either the devel list or the user community list will get developers' attention.  https://inkscape.org/en/community/mailing-lists/  Or there's IRC, where likewise, there is a development channel and a user channel.  And likewise, either one will be seen by developers.  https://inkscape.org/en/community/discussion/

Edit
Also I'm curious about the gcode.  Are you using Inkscape's gcode tools for that?  It seems odd to me that simply having a width which is not an even integer value would add so much more code.  I'll just bet that all that extra code has more to do with that transform attribute, than the size of the object.  Not that I'm an expert of course.  But I have that suspicion.
  • 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                       

September 06, 2017, 11:27:24 AM
Reply #2

Marek

  • Sr. Newbie

  • Offline
  • **

  • 2
Hi,

Please refer to attached pictures. When first rectangle is selected, we can read dimensions out from XML and top bar. They are equal. After combining 2 shapes together, you can read bounding box size at the top bar and M attribute of  the shape. It is easy estimate that result object is much bigger (almost 4x). Please notice that its shape had to be scaled down by 0.26 coefficient in order to be looking like components of operation.

Please do test as I described: remove transformation from XML and see what will happen. The shape will be large. The difference has not to be calculated. It is visible at first glance.

Yes, I know where is point (0,0) and how the objects are related to this. But it has nothing to do. Please compare the size of components to result object with removed transform attribute. No matter where they are on the canvas. There is no reason why result object should be enlarged almost 4x.


Regarding to preferences.
My setting Preferences > Behavior > Transforms is set to Optimized. Since I changed it to Preserved - nothing happened. Combining of shapes produces scaled object by 0.26... Of course it happens only when display units are set to mm as I mentioned. When the are changed to px, the transform attribute of result shape is empty (it means that result shape dimensions are properly calculated and need not to be scaled down).   

Regarding to g-codes.
No, I,m not using Inkscape to produce g-codes. I use the shapes from here and import them to CAM software (SimplyCAM). Next 2.5D objects are prepared basing on imported SVG.  I think that problem with large amount of code is caused by rounding long floating point numbers. I analysed this g-code because I was curious why simple shape (looked like letter T) had produced so large number of g-code lines. Even horizontal lines have been divided into tens of segments!  Next, I performed experiment: manually rounded all numbers to 3 digits after comma in M attribute of shape (of course after combining transformation with M line using Apply Transform external plugin). Works perfectly! 
  • Inkscape version 0.92.2
  • Windows 10

September 06, 2017, 05:46:23 PM
Reply #3

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Just moving the objects after the 'combine' action will remove the transform (at least it does for me - select, arrow up, arrow down to end up in same position as before). I can't tell you why it's there in the first place, though. I guess it's another fallout effect from the 'unit change' in 0.92.

September 07, 2017, 09:01:33 PM
Reply #4

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Oh, I didn't realize you meant to look at the 2 smaller rectangles in XML Editor.  Now I can see what you're talking about. 

Yes, I do see the transform attribute.  I didn't see it before, because when I Unioned duplicates of the 2 rectangles, I moved them over from on top of the originals.  And I'm having the same experience as Moini.  As soon as I move it, the transform attribute goes away!

I don't think this is the problem, but could you double-check on Document Properties > Page tab > Scale Factor?  Is it set to 1.00000?  And you did not change the Viewbox setting, right?

It might be possible to reduce the decimal places.  But even so, your result is still not precisely what you want.

Would it fit within your workflow to move the cutting paths slightly, before sending to the CNC?  Even 0.001 mm move makes the attribute disappear. 

Or another option might be to revert back to the last version before this happens.  Oh, my old brain!  I think that was 0.91.

Moini, do you think this should be reported?
  • 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                       

September 08, 2017, 08:56:09 AM
Reply #5

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Probably, yes (if it's not known already). I can't see a reason for the additional transform to exist, I find it should rather be applied to the path. But I'm not a dev :)

September 09, 2017, 08:58:34 PM
Reply #6

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
I can't seem to find anything about it (although searching LP is tricky).  So I'll report, and let the managers decide if it's new or a duplicate.  If it's a duplicate, at least we might hope for a workaround or something.
  • 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                       

September 09, 2017, 09:29:53 PM
Reply #7

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Just thought of something, while reporting the bug.  Still don't understand why the extra decimal places creates so much extra gcode.  Could you try using something else to create the gcode.  Maybe there's an issue with the gcode tool??

Still reporting the bug though, because it's just weird that the transform attribute is created in the first place.

Of course it happens only when display units are set to mm as I mentioned. When the are changed to px, the transform attribute of result shape is empty (it means that result shape dimensions are properly calculated and need not to be scaled down).

When I tested with px for units, I get a transform attribute with a value "translate(0,352.36218)".  But I don't have any decimal places.  I'm thinking the difference between your test and my test might be the scale factor.  When you changed your units to px to test, did you also change the scale factor back to 1?  Because changing your units will change your scale factor.  (This seems like a crazy feature.  I wish I understood it better.)
  • 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                       

September 09, 2017, 09:48:28 PM
Reply #8

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
  • 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                       

September 12, 2017, 12:24:13 AM
Reply #9

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Please check the bug report again.  There's a new comment which suggests changing the Scale value.  Whatever the value which is suggested there, apparently Inkscape would not create the attribute at all.

That whole Scale setting is so frustrating.  Very few ordinary users understand what it is or how is works.  And whenever someone explains it to me, my eyes glaze over.  So hopefully the developers will eventually come up with something which most users don't have to understand, to be able to use it.
  • 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, 2018, 01:19:54 AM
Reply #10

mustaphab78

  • Sr. Newbie

  • Offline
  • **

  • 3

Disable stroke and give your shapes the requiered size, after the union both shapes will remain in their original size.
  • 92.2
  • windows 7