addam / Export-Paper-Model-from-Blender

Python addon for creating paper models in Blender (development version)
https://blenderartists.org/t/export-paper-model/476597
409 stars 54 forks source link

Fix DPI & single linked image position and size #36

Closed comac2k closed 8 years ago

comac2k commented 8 years ago

Hi! I've been playing around a bit with the export paper model script. Here are two fixes:

addam commented 8 years ago

Thanks! You have my respect for tracking down these few lines that make so much difference. By the way, which SVG software do you use? There has been an issue with Illustrator that might also have got fixed by your commits.

addam commented 8 years ago

wait... there is still something wrong. If I save "Single Linked", the DPI is perfect. The other two options produce results in about 29% of the given resolution and I think I know why. Are you sure that the results are correct on your computer?

comac2k commented 8 years ago

Hi Addam!

"single linked" worked ok as it was. It's handled by a different method than the other two options and i didn't touch anything in that method.

For the other two options, you pass a "scale" parameter, calculated as the printable height multiplied by ppm. Or, in other words, scale is the number of pixels in the printable area (vertically). Then, inside the method generating the pictures, you multiply scale by the pictures bounding box dimensions (in blender units, which are assumed to be meters everywhere in the script). That doesn't make any sense.

Right formula should be:

Image_pixels = bounding_box x ppm

But, with the original "scale" parameter before my modifications, you get:

Image_pixels = bounding_box x ppm x printable_area_height

Assuming the default paper size and margins, the printable height is 297 - 2*5 millimeters = 0.287 meters = 0.287 blender units. That would explain the 29% resolution you're getting. This would seem to indicate you're still using the old code.

So, are you 100% sure you're running the right version of the script? I tested all options myself and found them to be accurate. How are you checking the resulting resolution? On Jan 20, 2016 10:20 PM, "addam" notifications@github.com wrote:

wait... there is still something wrong. If I save "Single Linked", the DPI is perfect. The other two options produce results in about 29% of the given resolution and I think I know why. Are you sure that the results are correct on your computer?

— Reply to this email directly or view it on GitHub https://github.com/addam/Export-Paper-Model-from-Blender/pull/36#issuecomment-173362396 .

addam commented 8 years ago

Oops, yes, I somehow still had the old version installed. Your calculations are correct.

I got confused by my own false comment in the code, which I deleted right now. Now it all works perfectly. Thanks again for the patch.

I'll push these changes into the addons-contrib repo in a few days.

comac2k commented 8 years ago

Oh! And I missed your first message. I'm using Inkscape on OS X to edit SVG files. Maybe I have a copy of Illustrator somewhere and I could take a look at it.

In any case, I didn't even see the background picture in Inkscape. The units in the SVG file are milimeters but the position and size of the background picture was writen in meters, resulting in a 1/1000 scale. Also, if I remember correctly, the variables being writen were vectors instead of scalars. So, the tags ended up like translation(Vector<0.005, 0.005> Vector<0.005, 0.005>) instead of translation(5 5). I wonder how it could work for some software.

I'll try to take a look at this illustrator issue if I can find the time and I'll post on that issue whatever I find.