Model's save method, about chinese filename and path
-
HI,all,
A problem, about model's save method. don't support the Chinese filename and path. It's ok for Sketchup's open_file method. such as:
Sketchup.open_file "/Users/liuzhenyi/Desktop/中文/测试.skp"
-> true
model = Sketchup.active_model
model.save "/Users/liuzhenyi/Desktop/中文/测试.skp"
-> nil
How does it work? Thank you!ODM.
-
Where do you get the string from? A .rb file?
Ruby 1.8 doesn't support Unicode characters. You might be encountering some problems related to that, that somehow the string with the path is mangled.
http://forums.sketchucation.com/viewtopic.php?f=180&t=20657&p=205614
-
Thanks thomthom.
get string's method,see Tig's batchpurge plugin:
model=Sketchup.active_model
path=model.path.tr("\","/")then, path is "/Users/liuzhenyi/Desktop/中文/测试.skp" (use mac ox system).
I will try it use UnicodeEX module, thanks again.
-
@odm said:
model=Sketchup.active_model
path=model.path.tr("\","/")That might be your problem right there, you manipulate a Unicode string with Ruby. That might very well mess up the string.
( Sidenote: instead of
path=model.path.tr("\\","/")
make use of the File class to correct the path for you if needed.
path=File.expand_path( model.path )
http://www.ruby-doc.org/core-1.8.6/File.html#method-c-expand_path )But if you are dealing with Unicode characters, avoid manipulating the strings.
-
model = Sketchup.active_model path=model.path path1=File.expand_path(model.path) path2=model.path.tr("\\","/") path.class #-> string path1.class #-> string path2.class #-> string
path,path1 and path2, all class are string, all value are "/Users/liuzhenyi/Desktop/中文/测试.skp"
Whether it can be said path=path1=path2.
model.save method see:
http://code.google.com/intl/en/apis/sketchup/docs/ourdoc/model.html#save
Should be filename is string, use path "/Users/liuzhenyi/Desktop/en/en.skp" ,it's ok.Should make the save method, recognized the chinese filename and path.
unicode can solve? or rewrite the save method. SketchUp 8.0 Ruby version is 1.8.6,maybe sketch up 9.0 will support....thomthom,Thanks a lot .
-
I would like to support chinese path as Sketchup's open_file method, model's save method why not support it?
Advertisement