lost dimensions in hpgl ( "selfscaling" )

Bug #500125 reported by tuxcnc
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Undecided
Unassigned
UniConvertor
Fix Released
Undecided
Unassigned
python-uniconvertor (Ubuntu)
Triaged
Low
Unassigned

Bug Description

Im sorry, my english is as is.

Lets make an experiment :

1. Open new Inkscape and make an rectangle 100x50 mm, then <shift+ctrl+C> .
2. Save as .svg format and open - rectangle is 100x50 mm. OK.
3. Save as .plt format and open - rectangle is 124,750x62,250 mm now. Very bad !!! (Import is the same).
4. But it is not all : 124,750 / 62,250 == 2,004 not 2 (100 / 50 == 2).
    We can scaling 124,750x62,250 to 100x49,9 or 100,2x50 but 49,9 != 50 && 100 != 100,2.
    Maybe it is good tolerance for vinyl cutting, but not metal milling.
    And what when we forgot scaling ?

Revision history for this message
Alvin Penner (apenner) wrote :

Have you tried the hpgl output to see if it is what you want?
The hpgl output will be in units of precisely 1/40 mm = 0.025 mm. (and approximately one thousandth of an inch), which I believe is standard practice for hpgl.

Revision history for this message
tuxcnc (662909078-eranet) wrote :

Alvin Penner wrote 3 hours ago:

Have you tried the hpgl output to see if it is what you want?
The hpgl output will be in units of precisely 1/40 mm = 0.025 mm. (and approximately one thousandth of an inch), which I believe is standard practice for hpgl.

-------------

I made rectangle 1x1 mm - it is 50x50 hpgl units.
I export it to .plt file : IN;PU0,50;PD50,50;PD50,0;PD0,0;PD0,50;PD0,50;PU; - it is OK.
But when I open it or import it, I get rectangle 1,350x1,350 mm.
This new rectangle saved is : IN;PU0,63;PD63,63;PD63,0;PD0,0;PD0,63;PD0,63;PU; .
This new .plt file gives 1,675x1,675 mm when opened .....

Revision history for this message
Alvin Penner (apenner) wrote :

which version of uniconvertor are you running?
there has been some discussion of scaling previously at:
https://bugs.launchpad.net/inkscape/+bug/387946/comments/7

you can probably get the version number by running the command uniconvertor

Revision history for this message
tuxcnc (662909078-eranet) wrote :

1 mm is 40 hpgl units of course.

I made in KWrite file : IN;PU0,40;PD40,40;PD40,0;PD0,0;PD0,40;PD0,40;PU; .
It gives rectangle 1,1x1,1 mm in Inkscape.
This 0,1 mm is from "simplification threshold")and is another problem.

Now :

1. open .plt and save .plt - makes no diffrent in scale.
2. open .svg or new and save as .plt - gives hpgl unit 1/50 not 1/40 mm.

Some works, some works not ...

Revision history for this message
Alvin Penner (apenner) wrote :

this sounds similar to the scaling problem discussed previously in Bug 387946, which was encountered when using uniconvertor 1.1.4, are you running version 1.1.4?

Revision history for this message
tuxcnc (662909078-eranet) wrote :

Uniconvertor is 1.1.4.
Systems are :
1. Slax 6 with Python 2.6 from sources, and precompiled Inkscape 0.47 from Slax site.
2. openSUSE 11 with Python 2.5 suse rpm and Inkscape 0.47 compiled myself .

Both systems give the same results.

Revision history for this message
Alvin Penner (apenner) wrote :

in that case I would suggest you try the .hpgl output, not the .plt output, because there is a bug in the uniconvertor output that is used for the .plt file. If you select .hpgl, then you can rename it to be .plt if you like, and I think you will find it is scaled correctly.

Revision history for this message
tuxcnc (662909078-eranet) wrote :

Good news !

In file UniConvertor-1.1.4/src/app/plugins/Filters/pltsaver.py
.....
 def SaveDocument(self, doc):
  left, bottom, right, top=doc.PageRect()
  inch=int(self.options['per_inch'])
  sc=inch / 72.0

  self.trafo=Trafo(sc, 0, 0, sc, 0, bottom*sc)
  self.Scale=sc
  self.inch=inch
  self.extend=map(rndtoint, tuple(self.trafo(left,bottom))
         + tuple(self.trafo(right,top)))

  # Header
  self.write_headers()
  self.SaveLayers(doc.Layers())
  self.write_terminator()
  #end
.....

I made change to sc=inch / 90.0 and compile Uniconvertor.

Now works.

I try < uniconv somefile.svg somefile.plt > and works too.

The question is, where is bug ?

In Uniconvertor because is 72 not 90 or in Inkscape because export resolution is 90 not 72 ?

Maybe patched Uniconvertor will not work properly with files from others programs ?

Now :

1. There is 0,1 mm added to both dimensions of objets of opened or imported .plt files.
    It is from "simplification threshold", I suppose, but I have no idea how fix it.

Revision history for this message
Alvin Penner (apenner) wrote :

this is a uniconvertor problem, as discussed in:

https://bugs.launchpad.net/inkscape/+bug/387946/comments/7

Revision history for this message
tuxcnc (662909078-eranet) wrote :

This problem is in menu <save as>, in Inkscape.

Of course it is from Uniconvertor code, but its author is not interested in fix it, I see.
What is your proposition ?
Wait for end of universe ?

Maybe simply patch can fix it now, not in far future.

Uniconvertor is standalone tool too.
I have no .svg files from Corel and Ilustrator.
I dont now is factor of 90 good for converting those files to plt.
Is problem somebody check it ?

What about this 0,1 mm ?

After open or import .plt files 1x1 mm is 1,1x1,1 mm and 100x100 mm is 100,1x100,1 mm.
Somewhere this magic 0,1 mm is added to all objects.
It is not linear and scaling is nothing to do with it.
Is it from Uniconvertor too ?
Im not familiar with svg format and cant check it.

su_v (suv-lp)
tags: added: exporting importing uniconvertor
Revision history for this message
Alvin Penner (apenner) wrote :

I would suggest you try the output filetype Save As:
HP Graphics Language (*.hpgl)
Once you have produced an .hpgl file in this way, then you can rename it to be .plt if you like.

Revision history for this message
tuxcnc (662909078-eranet) wrote :

There is two subjects.

First is "scaling factor 1,25" in export to .plt.
Patch to Uniconvertor fix it for Inkscape.
It need check with files .svg from other programs like Corel and AI and make .diff file if OK.
Check not discusion.

Second problem is 0,1 mm added in import .plt files.
You can write in any text editor : IN;PU0,40;PD40,40;PD40,0;PD0,0;PD0,40;PU; and save as test.plt (eg.).
This is 1x1 mm rectangle.
Now you can draw 1x1 mm rectangle at position 0,0 in Inkscape and save it as test2.svg.
Now < uniconv test.plt test.svg >
test.svg and test2.svg are different.
Rectangles are different too.
Made in Inkscape is 1x1 mm, made from .plt is 1,1x1x1,1 in Inkscape window.
I dont now is from this 0,1 mm.
But it is always 0,1 mm added to any dimensions.
This is not scaling, but simple adding.
Im not familiar with .svg format.
I dont now is file produced by Uniconvertor good.
Bug may be in Uniconvertor (bad conversion) or in Inkscape (bad reading files produced by Uniconvertor).

Revision history for this message
max (maxim-s-barabash) wrote :

The coordinate system was based on the smallest units one of their plotters could support, and was set to 25 µm (i.e. 40 units per millimeter, 1016 per inch)

Uniconvertor use 1016 per inch.
In this case, IN; PU0, 40; PD40, 40; PD40, 0; PD0, 0; PD0, 40; PD0, 40; PU;
equal to the square with sides 0.9906 mm

There were problems of scaling objects when importing svg, but they have already been resolved in the trunk sK1.

At this time we are working on improving the import / export svg formta in sK1/Uniconvertor

Revision history for this message
tuxcnc (662909078-eranet) wrote :

Thank max, but 0,9906 is not 1,1.

And 40 units is 1,1 mm and 400 units is 10,1 mm and 4000 units is 100,1 mm.

This is not scaling problem !

Revision history for this message
su_v (suv-lp) wrote :

tuxcnc - please attach your test files showing the 0.1 mm increase you perceive as result of an incorrect PLT import into Inkscape.

The 0.1 mm increase in size you see in Inkscape is most likely due to your
1) using the 'visual' selection bounding box mode which includes the stroke width of the selected object(s) (UniConvertor sets the stroke width to 0.1 mm) and
2) subsequently misinterpreting the selection width and height (bbox including all selected objects) as object width and height (width and height from node to node respectively from the axes of the path segments).

Please try one of the following ways to check the correctness of the PLT import:
a) switch to the node tool <F2>, select a node and check the coordinate values on the node tool controls bar (after setting it to 'mm' units)
b) change the preference for the selection bounding box to 'geometric' (in 'Inkscape Preferences > Tools > Bounding box to use')
c) remove the stroke from the rectangle and use a fill color only

In my tests width and height of the rectangle (svg path) are correct (tested Inkscape 0.47+devel on OS X 10.5.8, Python 2.6.2 with UniConvertor 1.1.5 from SVN, based on a plt file saved in the texteditor with 'IN;PU0,40;PD40,40;PD40,0;PD0,0;PD0,40;PU;')

Revision history for this message
max (maxim-s-barabash) wrote :

Inkscape account Thickness stroke of the object.
Remove the stroke and get 1mm

Revision history for this message
tuxcnc (662909078-eranet) wrote :

max wrote 1 hour ago:
Inkscape account Thickness stroke of the object.
Remove the stroke and get 1mm

---------------

Thanx.

What we know now :

1. There is "default export resolution" in preferences, but changes does nothing.
2. Patch to Uniconvertor 1.1.4 ( 90 in place of 72 ) fix problem of "selfscaling" in export from svg to plt.
3. There is no problem in Uniconvertor 1.1.5, ~suv wrote.
3. There is "undefined" stroke of objects imported from .plt files.
    "Undefined" is 0,1 mm we see.

"Undefined" stroke must be zero (none).
Changes of "default export resolution" in preferences must takes effects.

Thats all, I suppose.

Revision history for this message
su_v (suv-lp) wrote :

Proposing to close this report as 'Invalid' in Inkscape:

1) "default export resolution": as stated in the preferences this
   applies to *bitmap export* not export in general.
   The internal scale is fixed (by default) to 90 dpi:
   <http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Coordinates.html>.
2) "selfscaling" bug is not related to Inkscape:
   different solution already implemented in UniConvertor trunk.
3) "There is "undefined" stroke of objects imported from .plt files."
   The fill and stroke attributes are correctly assigned and
   not 'Unset' (You have to enter the top-level group to select
   the object itself - groups do have fill and stroke attributes
   unset per default).
4) ""Undefined" stroke must be zero (none)."
   Again this must be addressed by UniConvertor. OTOH the current
   attributes are the most logical thing to use when converting from
   a plot file (line-based) to SVG - at least IMHO.

@tuxcnc - what do you expect to get if fill is 'None' and stroke is 'Unset'? (hint: the path will not be visible):

UniConvertor output:
(…)
<g>
 <path style="stroke:#000000; stroke-width:0.283286; fill:none" d="…"/>
</g>
(…)

Revision history for this message
tuxcnc (662909078-eranet) wrote :

~suv wrote :
(hint: the path will not be visible)

---------

And it is correct.
Path is not visible, but exist.
It is <view outlines> to see objects without strokes.

Hpgl format is not for web sites designers.
It is for control vinyl cutters for example.
Knife have no stroke.

Revision history for this message
max (maxim-s-barabash) wrote :
Revision history for this message
tuxcnc (662909078-eranet) wrote :

~suv wrote:
 <path style="stroke:#000000; stroke-width:0.283286; fill:none"

---------

Thanx.

The <path style="stroke:#000000; stroke-width:0; fill:none" is correct.
Object is not visible in normal view, but visible in "view outlines" mode, and have correct dimensions.

The <path style="stroke:#000000; stroke-width:0.04; fill:none" is always visible and only 0,035 mm is added.
0,035 is not important in normal use.

Revision history for this message
su_v (suv-lp) wrote :

> Hpgl format is not for web sites designers.
> It is for control vinyl cutters for example.
> Knife have no stroke.

But Inkscape isn't a plotter, it's a vector editor ;) Or did I misunderstand you and the issue is that the stroke-width interferes with the PLT output?

If you need to, you can select all objects after opening a PLT file in Inkscape (Ctrl+A) and remove the stroke for all: click on the stroke color swatch (it displays the 'Unset' label if you don't ungroup the elements first) in the lower left corner of the Inkscape window, use the context menu (right-click with the mouse) and choose 'remove stroke'.

<http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Anatomy.html#styleindicator>
<http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Attributes.html>

Revision history for this message
tuxcnc (662909078-eranet) wrote :

~suv wrote:
it's a vector editor

-------------

Vector have length and direction only.

If vector must have thickness - it is not vector.

Revision history for this message
su_v (suv-lp) wrote : [Bug 500125] Re: lost dimensions in hpgl ( "selfscaling" )

@max - I confirm the scaling issue in UniConvertor 1.1.5 r187 when
converting SVG->UniConvertor->PLT, but not in PLT->UniConvertor->SVG:

steps to reproduce:
1) open attached '500125-a4-20x20mm.svg' (a4 page created in Inkscape)
2) save copy as *.plt
3) save copy as *.hpgl (Inkscape internal python script hpgl_output.py)
4a) open '500125-a4-20x20mm.plt' in Inkscape
4b) open '500125-a4-20x20mm.hpgl.plt' (renamed HPGL file) in Inkscape
5) compare the SVG rendering of both plotter files:
- PLT file is out of scale
- HPGL file is correctly scaled

conclusion (and confirmation): SVG->UniConvertor still has a scaling
issue in UniConvertor 1.1.5 SVN HEAD.

Revision history for this message
su_v (suv-lp) wrote :

> Vector have length and direction only
Attributes like stroke and fill don't change the _geometry_ of vectors.

Revision history for this message
max (maxim-s-barabash) wrote :

~suv, I confirm the scaling issue in UniConvertor 1.1.5 r187
1. error Scaling svg -> uniconvertor corrected.
Igor why have not sent a patch in trunk uniconvertor I do not know.
Perhaps due to the transfer of this part sk1libs.

2. In the example above, HPGL filter gives an error of 0,025 mm

su_v (suv-lp)
tags: removed: importing
Changed in uniconvertor:
status: New → Confirmed
Revision history for this message
tuxcnc (662909078-eranet) wrote :

Month gone and there isnt any changes in Uniconvertor source, isnt it ?

Revision history for this message
max (maxim-s-barabash) wrote :

Improved filters are located in svn
https://sk1.svn.sourceforge.net/svnroot/sk1/trunk/sK1/src/app/plugins/Filters/

1. You can copy plt and svg filters in the uniconvertor
2. Wait until the next release uniconvertor.
3. Use editor sk1 from svn
or
4. use the council https://bugs.launchpad.net/inkscape/+bug/500125/comments/11

best regards

Revision history for this message
max (maxim-s-barabash) wrote :

UniConvertor 1.1.5 is release
http://sk1project.org/news.php?readmore=63

Revision history for this message
Stefan Nagy (stefan-nagy) wrote :

UniConvertor 1.1.5 solves the scaling issue for me. Thanks!

Changed in python-uniconvertor (Ubuntu):
status: New → Confirmed
Changed in uniconvertor:
status: Confirmed → Fix Released
Revision history for this message
C de-Avillez (hggdh2) wrote :

Marking Triaged/Low, per request on #ubuntu-bugs.

Changed in python-uniconvertor (Ubuntu):
importance: Undecided → Low
status: Confirmed → Triaged
Revision history for this message
Stefan Nagy (stefan-nagy) wrote :

This bug is still present in Natty even though UniConvertor version 1.1.5 (was released in June 2010) fixes it – please update Debian & Ubuntu packages (see bug 637800).

Revision history for this message
su_v (suv-lp) wrote :

Closing for Inkscape - fixed upstream in UniConvertor 1.1.5.

Changed in inkscape:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.