sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    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

      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
      • thomthomT Offline
        thomthom
        last edited by

        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

          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
          • thomthomT Offline
            thomthom
            last edited by

            @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

              
              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

                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
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement