techDraw templates and text

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
wandererfan
Veteran
Posts: 6309
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: techDraw templates and text

Post by wandererfan »

RobertSwank wrote: Sun Jan 08, 2023 3:20 am
The transform clause for SheetNumber doesn't specifiy a rotation center, so the rotation is done around (0, 0) which puts it far off page to the left/top. Inkscape gets away with this by recomputing the rotated x&y positions of the <text> block, but anybody else trying to interpret the geometry from coordinates is going to be surprised.

You want your transform specified like this

Code: Select all

  <text
     transform="rotate(90, 14.9, 414.36591)"
     freecad:editable="SheetNumber"
     id="text3331-5-9-4-3-9-7"
     x="14.900037"
     y="414.36591"
     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:8.46667004px;line-height:125%;font-family:Arial;-inkscape-font-specification:'Arial, Condensed';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.0549527;stroke-linecap:butt;stroke-linejoin:miter">
    <tspan
     x="14.900037"
     y="414.36591"
       id="tspan762">NO</tspan>
  </text>
to get this
BOB-ANSI_B_Portrait_V2_plain_RotateCenter.png
BOB-ANSI_B_Portrait_V2_plain_RotateCenter.png (36.86 KiB) Viewed 874 times
It isn't mandatory, but you probably want templates to be saved as "plain svg" instead of "inkscape svg", and you also want to remove the "xml:space="preserve"" clauses, as they sometimes cause trouble.
Attachments
BOB-ANSI_B_Portrait V2_plain.svg
(35.63 KiB) Downloaded 29 times
RobertSwank
Posts: 13
Joined: Fri Dec 09, 2022 3:33 pm

Re: techDraw templates and text

Post by RobertSwank »

wandererfan wrote: Sun Jan 08, 2023 4:25 pm
RobertSwank wrote: Sun Jan 08, 2023 3:20 am
The transform clause for SheetNumber doesn't specifiy a rotation center, so the rotation is done around (0, 0) which puts it far off page to the left/top. Inkscape gets away with this by recomputing the rotated x&y positions of the <text> block, but anybody else trying to interpret the geometry from coordinates is going to be surprised.

You want your transform specified like this

Code: Select all

  <text
     transform="rotate(90, 14.9, 414.36591)"
     freecad:editable="SheetNumber"
     id="text3331-5-9-4-3-9-7"
     x="14.900037"
     y="414.36591"
     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:8.46667004px;line-height:125%;font-family:Arial;-inkscape-font-specification:'Arial, Condensed';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.0549527;stroke-linecap:butt;stroke-linejoin:miter">
    <tspan
     x="14.900037"
     y="414.36591"
       id="tspan762">NO</tspan>
  </text>
to get this
BOB-ANSI_B_Portrait_V2_plain_RotateCenter.png

It isn't mandatory, but you probably want templates to be saved as "plain svg" instead of "inkscape svg", and you also want to remove the "xml:space="preserve"" clauses, as they sometimes cause trouble.
OK, I saved these out as plain svg instead of inkscape, and edited with notepad to enter the coordinates and delete the "xml:..." clauses. When I enter the same coordinates as suggested (see plain2) the text disappears totally in FreeCAD, and no handle. However, when I enter rotate(90,0,0) the text displays as expected but still without the handle (see plain3). Seems maybe there is something else going on?

BOB-ANSI_B_Portrait V3-plain3.svg
(35.96 KiB) Downloaded 34 times
BOB-ANSI_B_Portrait V3-plain2.svg
(35.97 KiB) Downloaded 31 times
User avatar
wandererfan
Veteran
Posts: 6309
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: techDraw templates and text

Post by wandererfan »

RobertSwank wrote: Sun Jan 08, 2023 10:09 pm
You have X&Y reversed. Ansib is only 279mm wide so the handle is going off page to the right and above the top of page by 12 mm. I don't think x = -12 is right because that will put things off page to the left.

This

Code: Select all

  <text
     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:8.46667px;line-height:125%;font-family:Arial;-inkscape-font-specification:'Arial, Condensed';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.0549527;stroke-linecap:butt;stroke-linejoin:miter"
     x="12"
     y="411.22397"
     id="text3331-5-9-4-3-9-7"
     freecad:editable="SheetNumber"
     transform="rotate(90,12,411.22397)"><tspan
       id="tspan762"
       x="12"
       y="411.22397">NO</tspan></text>
gets you this
ansib-xyfixed.png
ansib-xyfixed.png (30.71 KiB) Viewed 828 times
Attachments
BOB-ANSI_B_Portrait V3-plain2_xy.svg
(35.95 KiB) Downloaded 32 times
RobertSwank
Posts: 13
Joined: Fri Dec 09, 2022 3:33 pm

Re: techDraw templates and text

Post by RobertSwank »

wandererfan wrote: Sun Jan 08, 2023 10:49 pm
RobertSwank wrote: Sun Jan 08, 2023 10:09 pm
You have X&Y reversed. Ansib is only 279mm wide so the handle is going off page to the right and above the top of page by 12 mm. I don't think x = -12 is right because that will put things off page to the left.

This

Code: Select all

  <text
     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:8.46667px;line-height:125%;font-family:Arial;-inkscape-font-specification:'Arial, Condensed';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.0549527;stroke-linecap:butt;stroke-linejoin:miter"
     x="12"
     y="411.22397"
     id="text3331-5-9-4-3-9-7"
     freecad:editable="SheetNumber"
     transform="rotate(90,12,411.22397)"><tspan
       id="tspan762"
       x="12"
       y="411.22397">NO</tspan></text>
gets you this
ansib-xyfixed.png
WOW! This is weirdness. I just did some experimenting in Inkscape with its xml editor open. When I rotate the text, Inkscape transposes the x and y coordinates for the text. Somehow, when I save the rotated version and reopen it in Inkscape, it still locates and displays the text in the right lace, even with the coordinates transposed. It must have some other means of referencing the location, I guess. Inkscape does load and display your edited file correctly. I then went back to my original file and added the rotation command in notepad, using its original coordinates. Inkscape displayed it but moved it a few millimeters. When I used Inkscape's transform features to move it to the right location (a couple mm), and also when I just dragged it to the right location with the mouse, in the XML editor window it transposed the x and y and made the transposed coordinate negative. Saving/Reopening the file and Inkscape still displays it in the correct location! How can this be?

Aha! I think when you rotate text in Inkscape, it uses 0,0 as the reference, then locates the text with a localized coordinate for the text, with y being the y of the text with a negative distance from 0,0 which actually locates it in the global x location. likewise with the transposed x coordinate. But how does it know this? And then how does it interpret your version of the file correctly? Questions for the Inkscape developers????

So, is there a different vector program that doesn't do this, or am I going to have to manually adjust rotated text to get it to work in FreeCAD? I am not a programmer - this experiment has touched my current capability :-)
User avatar
wandererfan
Veteran
Posts: 6309
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: techDraw templates and text

Post by wandererfan »

RobertSwank wrote: Mon Jan 09, 2023 3:21 pm So, is there a different vector program that doesn't do this, or am I going to have to manually adjust rotated text to get it to work in FreeCAD? I am not a programmer - this experiment has touched my current capability :-)
I have a bit of a love/hate relationship with Inkscape. It's great most of the time, but then it will throw a curve like this rotate business or changing the XY coords of an item and throwing a transform clause into the code in an unexpected location.

Come back if you get stuck. We can help get your templates sorted.
RobertSwank
Posts: 13
Joined: Fri Dec 09, 2022 3:33 pm

Re: techDraw templates and text

Post by RobertSwank »

wandererfan wrote: Tue Jan 10, 2023 12:01 am
I have a bit of a love/hate relationship with Inkscape. It's great most of the time, but then it will throw a curve like this rotate business or changing the XY coords of an item and throwing a transform clause into the code in an unexpected location.

Come back if you get stuck. We can help get your templates sorted.
OK, thanks for all your help. To follow the weirdness to the next step, I just created a landscape version of my template, by grouping the whole template and rotating it and then changing the page orientation to landscape. Now, in the XML editor, Inkscape has inverted all the coordinates, but has NOT included a transform command. Pulling the sheet into FreeCAD, the text is all shown in the correct place, but all the handles are still in the original locations! Weird beyond weird! I think I can fix it from here....
Post Reply