Blendigo Works Fine with Japanese Characters Now
|
Failed because of the garbled characters |
When you want to use external resources in Blendigo, which mean some pictures for texture, those for bump map, etc, you will specify the address to the files.
Sometimes I have to use the address which includes Japanese characters to specify the desktop path for my brief tests with Blendigo, but it causes a problem with getting characters garbled.
So, I took a look into the source code of the script, tested to find out what causes the problem, changed a little bit of the code, and it seems to have been fixed, at least on my computer.
Here is the code which I changed from blendigo_v1113.py:
blendigo_v1113_mHansPG.py
What's the Problem?
|
Selected picture file. [Zoom] |
It would happen if you use the computers that treat Japanese characters. In order to see the problem, go to the tab Materials in Blendigo, select a picture file that is in desktop for the setting Albedo and export .igs file by clicking the buttn EXPORT Scene in the tab Camera.
When you open the exported .igs file, you will see the garbled characters "...\デベハトップ\..." in the element <path>, which should be "...\デスクトップ\...". Indigo doesn't run with this .igs file, ending up with the error SceneLoaderExcep.
|
The garbled characters "...\デベハトップ\..." in the element <path> in the exported .igs file. [Zoom] |
What's the Cause?
I understood that Blendigo calls the function relpath for all the file addresses that are going to be written in the .igs file in exporting. In relpath, this code os.path.normcase(target) is used and I found out that makes the Japanese characters garbled.
To make it easy, I created a small code as follows, and I confirmed it was the cause (.blend file).
# -*- coding: MS932 -*-
import os
filename = "../デスクトップ" # japanese charactors that mean desktop
print "Just print filename:\n", filename, "-> good"
print "Print after normcase:\n", os.path.normcase(filename), "-> wrong" # this causes a problem to some of japanese charactors
def normcase2(text):
if os.path.normcase("/") == "\\":
return text.replace("/", "\\")
else:
return os.path.normcase(text)
print "Improved normcase2:\n", normcase2(filename), "-> good!" |
A small code to confirm cause (.blend file) |
If you run the code in the Text window in Blender, you will get the result in the console as follows. It shows that the function normcase changes it into something wrong.
|
The result in the console if you run the code in Blender |
Avioding it
To aviod this, I defined another slight function named as normcase2 and I changed a little bit of the code in relpath by calling normcase2 instead of normcase. Mainly, normcase2 does nothing, but I found in the manual of python that normcase replaces "/" with "\" in Windows, so normcase2 does the replacement.
Using normcase2, it seems to have been fixed, at least on my computer. However, I don't know well how normcase works, so the changed code might cause another problem in a different environment, though.
|
The fixed characters in the element <path> in the exported .igs file. [Zoom] |
|