Jump to content
You must now use your email address to sign in [click for more info] ×

SVG Hierarchy, relative x y coordinates?


Recommended Posts

So I'm not sure if I'm missing something.

When I export a file with layers and groups into SVG and have "relative coordinates" checked, it seems that the coordinates of the elements within a group are not relative to the parent at all?

My goal is to have a hierarchy of all my layers and have their x y coordinates be relative to their parent object. Right now it seems as though the x y coordinates are always relative to the 'canvas'
I am only mildly familiar with the SVG code structure so I may be misunderstanding what I am reading, but a lot of the x y values I am reading do not seem relative to their parents. 

I will try to provide an example soon. I am currently unable to access AD at the moment and I just wanted to see if some knowledgeable folk would know why "relative coordinates" are not exactly relative?

Thanks,

sig2.png.950594012af1a9c5582236e0a457cd0a.pngsig1.png.975f263a1c12b5aec3f87a4541eb33ef.png

Illustrator, Designer, 3D Modeller (In that order) - Open for commissions - Check out my art Instagram or follow me on twitter or like my Facebook page. Phew! 

Link to comment
Share on other sites

If it's always like that reproducable, it might be they overlooked to change and add groups and nested layers etc. also then into the chain of SVG code generation. In the past there were some things fixed done for SVG export with "relative coordinates" but maybe not taken into account under all circumstances then. - See:

BTW an interesting read in relation to SVG and relative positioning is this here.

 

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

Thanks for the reply v_kyr. I saw that thread. 
I'd be kinda surprised if it was overlooked and nobody noticed but I guess there may not be a lot of people using AD SVG exports.

38 minutes ago, v_kyr said:

BTW an interesting read in relation to SVG and relative positioning is this here.

I took a look at that page earlier; seems like exactly what I want but I'm not sure how I would go about making certain layers or groups be treated as SVGs within the export SVG. 

sig2.png.950594012af1a9c5582236e0a457cd0a.pngsig1.png.975f263a1c12b5aec3f87a4541eb33ef.png

Illustrator, Designer, 3D Modeller (In that order) - Open for commissions - Check out my art Instagram or follow me on twitter or like my Facebook page. Phew! 

Link to comment
Share on other sites

1 hour ago, Dclone2 said:

I'm not sure how I would go about making certain layers or groups be treated as SVGs within the export SVG

No chance, it doesn't support this. - Also when loading a file with nested SVG contents it won't position it correctly related to the parent (nested in SVG) coordinate system here, as you can try out with that above article's final bird-nest example.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

So experimenting a bit yielded this. This is using relative transforms and the coordinates are clearly not "relative"
SVGexpex.thumb.png.57322158c80ca8d6e1a09adb752c64ed.png

Structure:

- LVL1(Rect) SVG has  x=63.11 y=6.023 and is correct
- - LVL1_2(Grp) Seems groups don't get coordinates! Oh well

- - - LVL 1(Rect) SVG has x=63.11 y=6.023 and should be x=0 y=0

- - - - LVL1_2(Grp) Seems groups don't get coordinates! Oh well

- - - - - LVL 1(Rect) SVG has x=63.11 y=6.023 and should be x=0 y=0

- LVL2(Grp) Seems groups don't get coordinates! Oh well
- - LVL2_1(Grp) Seems groups don't get coordinates! Oh well

- - - LVL 2_3(Rect) Seems groups don't get coordinates! Oh well

 

Even though all boxes are aligned, top-left corner, and nested, somehow all boxes have the same x y coordinates. The nested ones should definitely have x=0 y=0 coordinates if they should be relative to their parents. If I'm misunderstanding what the use of "use relative coordinates" is, please let me know :/

SVGTester.afdesign

sig2.png.950594012af1a9c5582236e0a457cd0a.pngsig1.png.975f263a1c12b5aec3f87a4541eb33ef.png

Illustrator, Designer, 3D Modeller (In that order) - Open for commissions - Check out my art Instagram or follow me on twitter or like my Facebook page. Phew! 

Link to comment
Share on other sites

Looks to always writes out absolute initial coordinate positions then instead. I don't think it takes parents coordinates into account at all.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

Just to give a comparison, this is how sketch writes to SVG, I've tried to mirror your test doc.

222476753_ScreenShot2019-02-02at18_55_54.png.73fefcbebcae3e03910a14d888f78561.png

<?xml version="1.0" encoding="UTF-8"?>
<svg width="630px" height="400px" viewBox="0 0 630 400" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <!-- Generator: Sketch 52.6 (67491) - http://www.bohemiancoding.com/sketch -->
    <title>Untitled</title>
    <desc>Created with Sketch.</desc>
    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <g id="LVL1-Group" fill-rule="nonzero" stroke="#979797">
            <g id="LVL1_2">
                <g id="LVL1_3">
                    <rect id="LVL1_3-Rectangle" x="0.5" y="0.5" width="79" height="79"></rect>
                </g>
                <rect id="LVL_1_2-Rectangle" x="0.5" y="0.5" width="159" height="159"></rect>
            </g>
            <rect id="LVL1-Rectangle" x="0.5" y="0.5" width="399" height="399"></rect>
        </g>
        <g id="LVL2" transform="translate(470.000000, 0.000000)" fill-rule="nonzero" stroke="#979797">
            <g id="LVL2_1">
                <rect id="LVL2_3-Rectangle-" x="0.5" y="0.5" width="159" height="159"></rect>
            </g>
        </g>
    </g>
</svg>

 

iMac 27" 2019 Somona 14.3.1, iMac 27" Affinity Designer, Photo & Publisher V1 & V2, Adobe, Inkscape, Vectorstyler, Blender, C4D, Sketchup + more... XP-Pen Artist-22E, - iPad Pro 12.9  
B| (Please refrain from licking the screen while using this forum)

Affinity Help - Affinity Desktop Tutorials - Feedback - FAQ - most asked questions

Link to comment
Share on other sites

  • 1 month later...

Thanks @firstdefence. I wish Sketch was on Windows! I would totally use that for my purposes...

I'm hoping there are plans to "fix" SVG settings in later versions. Stuff like Symbols and embedded images are also broken :S 

sig2.png.950594012af1a9c5582236e0a457cd0a.pngsig1.png.975f263a1c12b5aec3f87a4541eb33ef.png

Illustrator, Designer, 3D Modeller (In that order) - Open for commissions - Check out my art Instagram or follow me on twitter or like my Facebook page. Phew! 

Link to comment
Share on other sites

Well, Sketch isn't overall that much better here, it just performs a translate transform move and keeps initial object coordinate positions. See also ...

Further it seems too to have SVG problems ...

An interesting read about SVG coordinate systems is this series here ...

For inspecting and determining SVG contents etc., sometimes also tools like MacSVG can be handy and of help.

macsvg.jpg.a78465267108f7cadee2c281427e4c20.jpg

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.