Hi,
I modified a script, load_blend.py.
Already you know , it is a file chooser script that pops windows dialogue.
This script has a problem when it encode filepath.
I use
sys.stdout.encoding
as encoding , but I should use
sys.getfilesystemencoding()
in this case,I think.
I tested follow three pattern…
(1):sys.getdefaultencoding() - x(utf-8) not exitst
(2):sys.stdout.encoding - o(cp932)
(3):sys.getfilesystemencoding() - ?(mcbs) critical error
My environment:
OS : Windows 2000(JP)
blender: Ver. 2.44
python: Ver. 2.5
#!BPY
""" Registration info for Blender menus:
Name: 'Open .blend'
Blender: 237
Group: 'Help'
Tooltip: 'Open .blend files using standard Windows file dialog'
"""
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2005-2006 Mariano Hidalgo
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
__author__ = "Mariano Hidalgo AKA uselessdreamer"
__url__ = ("blender", "elysiun")
__version__ = "1.0"
__bpydoc__ = """
Allows you to open a .blend file using the standard Windows file dialog.
The script recalls your last chosen folder and defaults there. If the
folder no longer exists, it defaults to C:\\.
Needs a full Python installation to work (www.python.org).
"""
##modified for Japanese env , by manda[2007.05.20]
import Blender
import os
import sys
import tkFileDialog
import Blender.sys as Bsys
from Blender import Registry
from Tkinter import Tk
# get a encoding string (Is this correct?)
file_enc = sys.stdout.encoding
t = Tk()
t.wm_title("Open Blend")
t.wm_state("icon")
d = Registry.GetKey('OpenBlend', True)
if d:
last_folder = d['last_folder'].encode(file_enc) # encodings
else:
last_folder = u"C:\\"
if Bsys.exists(last_folder):
os.chdir(last_folder)
else:
os.chdir(u"C:\\")
f = tkFileDialog.askopenfilename(title="Open Blend",filetypes=[(".blend files", "*.blend")])
t.destroy()
if f:
d = {}
d['last_folder'] = Bsys.dirname((f).replace("/","\\"))
Registry.SetKey('OpenBlend', d, True)
if f[-6:] == ".blend":
g = f.encode(file_enc) # encodings
if Bsys.exists(g):
Blender.Load(g)
else:
Draw.PupMenu("Error!%t|Not a .blend file")
and sitecustomize.py ( C:/python25/Lib/site-packages/)
import sys
sys.setdefaultencoding("utf-8")
in blender 2.44 ,it can display Unicode characters on File Window.
but it is…
Thanks,