• Login
sketchucation logo sketchucation
  • Login
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

Model's save method, about chinese filename and path

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 2 Posters 476 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    ODM
    last edited by 26 Nov 2011, 13:12

    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.

    http://www.SketchUpBAR.com

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 26 Nov 2011, 13:31

      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

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • O Offline
        ODM
        last edited by 26 Nov 2011, 14:34

        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.

        http://www.SketchUpBAR.com

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 26 Nov 2011, 14:40

          @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.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • O Offline
            ODM
            last edited by 26 Nov 2011, 15:38

            
            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 .

            http://www.SketchUpBAR.com

            1 Reply Last reply Reply Quote 0
            • O Offline
              ODM
              last edited by 26 Nov 2011, 15:47

              I would like to support chinese path as Sketchup's open_file method, model's save method why not support it?

              http://www.SketchUpBAR.com

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              1 / 1
              • First post
                6/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement