Maniphest T76736

Problems of UV coordinates and SVG export
Closed, Resolved

Assigned To
Campbell Barton (campbellbarton)
Authored By
baoyu (baoyu)
May 14 2020, 10:22 AM
Tags
  • BF Blender
  • Modeling
Subscribers
baoyu (baoyu)
Campbell Barton (campbellbarton)
Philipp Oeser (lichtwerk)
Yevgeny Makarov (jenkm)

Description

System Information
Operating system: Windows 10 1903
Graphics card: rtx 2070 super and rtx 2080

Blender Version
Broken: 2.9 alpha and all older versions
Worked: none worked

Short description of error
No.1, 2D UV point average coordinate behaves differently from other 3D package or 2D programs.
No.2, when exporting uv as svg from a blender file whose name contains Chinese charactor, the result svg file would have encoding issue in <desc> block causing most software treat the svg file as borken file.
Detailed problem discription here https://devtalk.blender.org/t/problems-of-uv-coordinates-and-svg-export/13148

Exact steps for others to reproduce the error
Just try the attached blend file.


Based on the default startup or an attached .blend file (as simple as possible).

Revisions and Commits

rBA Blender Add-ons

Event Timeline

baoyu (baoyu) created this task.May 14 2020, 10:22 AM
baoyu (baoyu) updated the task description.May 14 2020, 10:25 AM
baoyu (baoyu) added a project: Modeling.May 14 2020, 10:49 AM
Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Needs Information from User.May 14 2020, 11:28 AM
Philipp Oeser (lichtwerk) added a subscriber: Philipp Oeser (lichtwerk).

Just a first stab in the dark:

Does it help to specifiy encoding? Changing it "by hand" to

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

or

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

Does the import in other software work then?

baoyu (baoyu) added a comment.May 14 2020, 11:55 AM
In T76736#931305, @Philipp Oeser (lichtwerk) wrote:

Just a first stab in the dark:

Does it help to specifiy encoding? Changing it "by hand" to

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

or

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

Does the import in other software work then?

Nope.
e.g. my blender file name is "你好测试.blender" ("Hello test.blender" in English), when I export uv map as svg, other programs wouldn't recognize it. When open that svg file in text editor, note the 6th line goes:

<desc>ÄãºÃ²âÊÔ.blend, (Blender 2.90 (sub 1))</desc>

It's these Chinese charator being wrongly encoded to some weird unicode. I guess some tweaks in the svg export python script would solve the issue. Though I could manually fix this issue using text editor, I thought maybe the developer could solve the inconvience once for all CJK language users.

Philipp Oeser (lichtwerk) added a comment.May 14 2020, 12:01 PM

Maybe a misunderstanding, what I meant is changing the first line in the svg file in a text editor and save, have you tried that?
(your first line still shows as <?xml version="1.0" standalone="no"?> -- no encoding specified...)

Yevgeny Makarov (jenkm) added a subscriber: Yevgeny Makarov (jenkm).May 14 2020, 12:10 PM

No.1

Here the average value for all vertices, some vertices are overlaid.

For example:

( 0.5 + 0.5 + 0.5 + 0.25 + 0.25 + 0.0 ) / 6 = 0.333

Yevgeny Makarov (jenkm) added a comment.May 14 2020, 12:28 PM

I have no problems with exporting svg and then opening it in Affinity Designer.

baoyu (baoyu) added a comment.May 14 2020, 1:02 PM
In T76736#931357, @Yevgeny Makarov (jenkm) wrote:

No.1

Here the average value for all vertices, some vertices are overlaid.

For example:

( 0.5 + 0.5 + 0.5 + 0.25 + 0.25 + 0.0 ) / 6 = 0.333

Thank you! If I don't misunderstand what you said, when I don't rip apart the uv faces, the uv points are just overlaping each other like this:

However, this agorithom is kind unintuitive to artist, especially for those who are used to 2D programs that thinks and manipulates things in 2D space.
I highly suggest we offer a choice to change this calc behavier!

baoyu (baoyu) added a comment.May 14 2020, 1:04 PM
In T76736#931360, @Yevgeny Makarov (jenkm) wrote:

I have no problems with exporting svg and then opening it in Affinity Designer.

Why? How did you make that happen?

baoyu (baoyu) added a comment.May 14 2020, 1:11 PM
In T76736#931360, @Yevgeny Makarov (jenkm) wrote:

I have no problems with exporting svg and then opening it in Affinity Designer.

Oh, I think I figured it out! Maybe it's be i18n thing. Can I see your translation config in Blender preference?
This is mine:

Yevgeny Makarov (jenkm) added a comment.May 14 2020, 1:32 PM

I use English, but I also tried switching to others.

Try "Load Factory Preferences" and then export.

baoyu (baoyu) added a comment.May 14 2020, 1:39 PM
In T76736#931407, @Yevgeny Makarov (jenkm) wrote:

I use English, but I also tried switching to others.

Try "Load Factory Preferences" and then export.

I was using automatic, and basically automatic is the same as English. I tried switch to English, that didn't work either.
Then I tried export after Load Factory Preferences, failed again.
BTW, thanks for your patience!

Ankit Meel (ankitm) changed the task status from Needs Information from User to Needs Triage.May 21 2020, 2:41 PM
Campbell Barton (campbellbarton) changed the task status from Needs Triage to Needs Information from User.Jun 2 2020, 10:57 AM
Campbell Barton (campbellbarton) added a subscriber: Campbell Barton (campbellbarton).

Please include the generated SVG, when I export this file on Linux I get the file name working properly:

baoyu (baoyu) added a comment.Jun 2 2020, 11:02 AM
In T76736#942610, @Campbell Barton (campbellbarton) wrote:

Please include the generated SVG, when I export this file on Linux I get the file name working properly:

Here's the svg I exported from
Blender 2.90.3 Alpha
Hash: 86fa8dc7f73a

Campbell Barton (campbellbarton) added a comment.EditedJun 2 2020, 11:07 AM

If you type this into the Python console, does it display the file path properly?

bpy.data.filepath

(press Enter).


I see:

PYTHON INTERACTIVE CONSOLE 3.8.3 (default, May 17 2020, 18:15:42)  [GCC 10.1.0]

Builtin Modules:       bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports:   from mathutils import *; from math import *
Convenience Variables: C = bpy.context, D = bpy.data

>>> bpy.data.filepath
'/d/你好测试.blend'

>>>
baoyu (baoyu) added a comment.Jun 2 2020, 11:09 AM

It returns:

>>> bpy.data.filepath
'C:\\Users\\jiabaoyu\\Desktop\\你好测试.blend'
Campbell Barton (campbellbarton) closed this task as Resolved.EditedJun 2 2020, 11:30 AM
Campbell Barton (campbellbarton) claimed this task.

Committed fix rBA86c4ca71ef180fd67fe64451f8533d5ca3f6417e

baoyu (baoyu) added a comment.Jun 2 2020, 11:32 AM

Good job Campbell!
Could you please check the other issue I posted ;)

Campbell Barton (campbellbarton) added a commit: rBA86c4ca71ef18: Fix T76736: incorrect filename in SVG, fails to load elsewhere.Jun 2 2020, 11:41 AM
Campbell Barton (campbellbarton) added a comment.Jun 2 2020, 2:34 PM

@baoyu (baoyu) Blender uses the median center for coordinates, this is working as intended, we could support this but it's not something we use the bug tracker for.

baoyu (baoyu) added a comment.Jun 2 2020, 2:47 PM

@Campbell Barton (campbellbarton) Thanks! I was trying to implement that feature by making a addon, though my python skill is on a low level and I can't find default api for manipulating UV coordinate :(