FS#2660 - Text in a scaled Block Reference is scaled twice in a SVG export.
Andrew,
Related to this forum topic where an export by dwg2svg fails in various ways.
The attached file in the topic has drawing unit ‘none’, the intended unit is ‘meter’.
The content of the given file is drawn extremely far form the origin (About 228 km away).
All this should not be a problem in any way.
A simple export with: dwg2svg.bat -o “_out_g_m.svg” -g -u m -f “input1.dxf” produces an export in mm (SVG limitation) but with no visible text.
We managed to get a better output with:
dwg2svg.bat -o “_out_1000mm.svg” -g -s 1000 -u mm -f “input1.dxf” We get a viewBox in meters and a scaled canvas in mm.
Values are then in meters and things are displayed 1000 times larger.
The first occurring text item in the SVG output is one in Model_Space:
Text at (148846.7038, 172548.9401); Height 0.35; Alignment Left Base
<!-- Text: 6.01 --> <text x="0" dx="0" y="0" dy="0.35" font-family="ARIAL.TTF" font-size="0.49" line-height="1.1" fill="#000000" transform="translate(148846.7038,172548.9401) translate(0,0.35) scale(1,-1)" text-anchor="start">6.01</text>
Breaking this down:
- SVG font size = 140% (Height of capital ‘A’ vs lower case for SVG) = 0.49
- Created at 0.35 (units=m) down what is the CAD height.
- Translated 0.35 up because alignment = Base, again the CAD height.
- Translated to its position in the drawing at (148846.7038, 172548.9401).
This text is visible and positioned correctly including the tweak -s 1000 -u mm.
The font may be incorrect depending the client.
‘ARIAL.TTF’ is listed as last in QCAD (As not a system font)
All the text items from Model_Space are now visible and sized correctly.
A Block Reference for Block ‘$TITLE_BLOCK’ is inserted in Scale (0.01, 0.01) at (148862.63734451, 172549.97956209);
For a text ‘Tekening’ at (100, -50); Height 100; Alignment Left Top the exports reads:
<!-- Text: Tekening --> <g transform="translate(148862.6373,172549.9796) scale(0.01,0.01)"> <text x="0" dx="0" y="0" dy="100" font-family="ARIAL.TTF" font-size="1.4" line-height="1.1" fill="#000000" transform="translate(1,-0.5) scale(1,-1)" text-anchor="start">Tekening</text> </g>
- SVG font size = 140% = 140 but scaled down by factor 100
- Created at 100 down what is the CAD height.
- Not translated up because alignment = Top.
- Translate within the Block is scaled down by factor 100.
- As group for a second time scaled down by factor 100
- As group translated to its position in the drawing at (148862.6373, 172549.9796).
Formatted following the rules seen in the Model_Space example this should read:
<!-- Text: Tekening --> <g transform="translate(148862.6373,172549.9796) scale(0.01,0.01)"> <text x="0" dx="0" y="0" dy="100" font-family="ARIAL.TTF" font-size="140" line-height="1.1" fill="#000000" transform="translate(100,-50) scale(1,-1)" text-anchor="start">Tekening</text> </g>
When manually adapted for all text items in the ‘$TITLE_BLOCK’ they appear at the intended location and in correct size. See file <_out_1000mm_rev1.svg>
Revision 1 because text of the $LEGENDRCT Block is still not visible.
Most probably outside the viewbox or too small.
I attached the related files here.
Regards,
CVH
I applied the same method for the text content of Block '$LEGENDRCT' with success.
dy = CAD height
font-size = 140% CAD height
local 'translate' as how the text is positioned in the Block.
Regards,
CVH