mDraw distorting SVG dimensions


#1

Anybody know why mDraw would be distorting the dimensions of an SVG when drawing with my XY plotter? I have an image which should be 203mm x 243 mm. But when I open it in mDraw and type in 203 for X it calculates Y to be 224. I suppose I could stretch the image in Inkscape to adjust for it shrinking in the Y dimension, but I’d kind of like it to work correctly instead.

I’m trying to use the plotter to copy pencil markings into multiple copies of sheet music. So it’s important that the scale is correct in both dimensions or the pencil markings won’t line up with the printed music.

I’m assuming this is user error.


#2

I have been looking at this issue on and off. It seems to happen in the svgparser.py module when the code finds the min and max X and Y points in the file it has read in and from this calculates the bounding rectangle to draw around the picture. This bounding rectangle then becomes the picture width and height that mdraw.py uses to adjust the ratio in subsequent resizes. It does this before resizing, so after it has changed one dimension it then resizes the second dimension to be a ratio of the first.

I have found one workaround. If I have an Inkscape drawing where there is a rectangle around the very outside of the drawing, I am able to get it to resize to the precise figure I created the drawing at when I alter either the height or the width. I assume from this that other drawings where the min and max are found by working through the paths are somehow skipping a point, but haven’t got all the way through the code. I am more concerned that mDraw misses two shapes from an Inkscape drawing I send it.

As a workaround for you, try putting a rectangle on the graphic that matches the page outline for the target print?


#3

Thanks Adrian. That’s too bad, I was hoping it was my fault! I was already going try to distort the SVG in Inkscape to accommodate the mDraw bug–shouldn’t be hard after learning the software. Please post on this thread when/if a fix is ready so we can update mDraw.

Is there a more functional alternative to mDraw for use on Mac? I’m currently using 10.10.3


#4

Oh also, if it’s an easier fix to the software could a feature be added like photoshop when resizing an image? Default is to maintain aspect ratio, but when unlocked X & Y can be changed independently. Perhaps mDraw could just increase the speed on one axis by a percentage to correspond to the stretched dimension. I’m just guessing at how things work.


#5

I just finished playing around with some debug lines in the code, and I can confirm that the svgparser module does not read the two entries width and height in the svg preamble, but instead works out a width and height from the max and min values it finds as it goes through the paths.

Like you, I need to get a very precise positioning on the page because I am using the laser to cut out pre-printed card sheets with models on them. It looks like the workaround therefore is to put a bounding rectangle in the Inkscape drawing. It may be possible to cheat a bit and set the draw and fill parameters for this bounding box to be the background colour so that mDraw doesn’t then try and draw or cut it. I’ll play later.

I can only test mDraw changes on Windows and with the XY Plotter, so I don’t think I will be releasing fixes since they would be un-tested on the other bots.

Just read your follow-up post. I don’t think you can unlock the aspect ratio that easily, because all of the paths have already been read and stored as a list of x-y points. The best thing to do is process the image in appropriate software such as Inkscape to make such transformations.


#6

I have no idea what’s available for MACs, my only MAC is a 1999 G4 which runs Lubuntu.

I looked a bit further inside SvgParser and managed to solve my problem of why not all of the Inkscape drawing was coming out (me forgetting to clone an object). However, I could not see an easy way of getting the specified width and height parameters in from the svg header node. Also, when I came to test another drawing which should have been 32mm by 20 mm I ended up with a drawing 32mm by 21.333mm. This variation in the ratio persisted even when scaling up the drawing, as it would of course, but in effect I cannot use SVG files reliably for what I want to do.

I think for what you and I and possibly a few others want, the most precise way is to use GCODE. Inkscape already has GCodetools as a supplied extension, There is enough free program space in the Arduino to add in a few routines to handle some extras such as Arcs if required. GRemote used this method. It is possible to send GCode and MCode direct to the Orion from mDraw by the bottom field anyway, what is lacking is the ability to stream a file. GRemote did have this.

There are two ways forward here, one is to add CNC file streaming to mDraw, the other is to resurrect GRemote and adapt it to use the more accurate steps_per_mm and acceleration/deceleration that mDraw introduced.


#7

I am attempting to use the XY plotter and mDraw to print on aluminum panels for my flight simulator. I have created the panels with exact dimensions in Inkscape and saved them as .SVG files. When I pull these files into mDraw, the dimensions are not even close and I have not figured out how to fix this. Even the orientation is not correct.

Has anyone come up with a fix for this other than what was posted in February?


#8

I think we’re all having the same issue, could someone from Makeblock fix the problem and update the next version of mdraw ? That would allow large tiled drawings, it would be sooo good !! :slight_smile:


#9

After more research and tests, I think this is what the svg loader does

  • Finds width of bounding box on X (distance between min and max values)
  • Finds height of bounding box on Y
  • The larger value is scaled down to 150mm keeping the svg ratio.

Svg size (height, width, viewbox etc… are all ignored).

FIX:

  • In your SVG, create a 4 small corners (with lines) exaclty at the corner of your artboard (for AI users) or document. this will be your bounding box (make sure there’s nothing outside that rectangle).
  • Load your svg in mdraw, it will be scaled down to 150mm
  • Scale your drawing back to the intended size. If the drawing starts with the rectangle, hold the pen up so the rectangle won’t be drawn.

Hope this helps, until we get a better fix.
Edit: They won’t ever be a fix, @makeblockdev @makeblock confirmed that they’re not planning on ever fixing mdraw.


#10

Dear @Adrian_S @ollie @Drew_Ford @tec_support

Did you guys find a solution ? I found the default scale dimensions in SVGParser.py (def resize(self,drawRect=(150,150,150,150)):slight_smile:
Any idea how to compile a new mdraw.exe with different values ?

A fix of this function would solve so many of our problems…
Any hints welcome :slight_smile:

Joanie


#11

Hi Joanie,

This is normal on mDraw software. The default setting of the opening size is 150 for width or height.
But you can drag the picture to its original size as you want when you going to draw it.


#12

Thanks ! Unfortunately this is very unprecise.
I understand there won’t be any fx/update from @makeblock, so I’d love to try adjusting the code myself, could you tell me how I can re-compile mdraw ?

Many thanks

HOWTO: compile mdraw for windows


#13