sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download

    [Plugin] Material_Maintenance v2.2 - 2013-01-13

    已排程 已置頂 已鎖定 已移動 Plugins
    155 貼文 19 Posters 55.0k 瀏覽 19 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • M 離線
      Myhand
      最後由 編輯

      @driven said:

      ` > 183.chr
      ·

      182.chr
      ¶`
      they are not the same as the original chars, I was seeing in my script editor, and the script is now saying it's encoded uft8, which it wasn't
      john

      Hi John, these are the actual char codes, I have not changed the JS side and these codes still work for me on windows.

      I will now also change them in JS to explicit ASCII values. Unfortunately I have to repackage the whole plugin then, so will take me a bit of time, but then again it is likely to work.

      http://www.keepingmyhandin.com/

      1 條回覆 最後回覆 回覆 引用 0
      • thomthomT 離線
        thomthom
        最後由 編輯

        SketchUp return strings in UTF-8. Anything above the ASCII character range will be multi-byte characters - which is easily mangled by Ruby 1.8's string manipulation methods as it treats 'characters' as single bytes.

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

        1 條回覆 最後回覆 回覆 引用 0
        • M 離線
          Myhand
          最後由 編輯

          @thomthom said:

          SketchUp return strings in UTF-8. Anything above the ASCII character range will be multi-byte characters - which is easily mangled by Ruby 1.8's string manipulation methods as it treats 'characters' as single bytes.

          But my characters are well within the ASCII range...? i.e. they still fit within a byte. from which value does it convert them to multi byte?

          http://www.keepingmyhandin.com/

          1 條回覆 最後回覆 回覆 引用 0
          • M 離線
            Myhand
            最後由 編輯

            Ok so here is a debug version with the the token chars explicitly specified in both JS and Ruby. Unfortunately you will have to un-install the whole plugin and install the debug version.

            It still has tracing code in, so will still be a bit slow.

            John, CMD can you test again please?

            Debug version

            http://www.keepingmyhandin.com/

            1 條回覆 最後回覆 回覆 引用 0
            • D 離線
              driven
              最後由 編輯

              !!!=> fromUIHandler: parameter string = 73-0¶__vz¶refreshMaterials¶true¶false¶false p1 = >>73-0Â<< p1 = >>__vzÂ<< p1 = >>refreshMaterialsÂ<< p1 = >>trueÂ<< p1 = >>falseÂ<< p1 = >>false<< calling function >>refreshMaterialsÂ<< Error: #<NoMethodError: undefined methodrefreshMaterials' for #<MH_KeepingMyHandIn::MaterialMaintenance:0x11b2f898>>
              /Users/johns_iMac/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb:121:in send' /Users/johns_iMac/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb:121:in fromUIHandler'`

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 條回覆 最後回覆 回覆 引用 0
              • M 離線
                Myhand
                最後由 編輯

                @driven said:

                !!!=> fromUIHandler: parameter string = 73-0¶__vz¶refreshMaterials¶true¶false¶false p1 = >>73-0Â<< p1 = >>__vzÂ<< p1 = >>refreshMaterialsÂ<< p1 = >>trueÂ<< p1 = >>falseÂ<< p1 = >>false<< calling function >>refreshMaterialsÂ<< Error: #<NoMethodError: undefined methodrefreshMaterials' for #<MH_KeepingMyHandIn::MaterialMaintenance:0x11b2f898>>
                /Users/johns_iMac/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb:121:in send' /Users/johns_iMac/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb:121:in fromUIHandler'`

                Hi John, thanks for testing is this output from the latest Material_Maintenance_debug.rbz file?

                If so did you fully delete the previous version, install and restart Sketchup?

                http://www.keepingmyhandin.com/

                1 條回覆 最後回覆 回覆 引用 0
                • D 離線
                  driven
                  最後由 編輯

                  Yes, I did it manually to start and when the results appeared to go backwards I deleted those and used SU to install the .rbz
                  exactly the same results

                  BTW. if you can put a 20px margin around your html, I can attach web Inspector to look at the js, I need a crack to get in...

                  learn from the mistakes of others, you may not live long enough to make them all yourself...

                  1 條回覆 最後回覆 回覆 引用 0
                  • D 離線
                    driven
                    最後由 編輯

                    !!!=> fromUIHandler: parameter string = 73-0|__vz|refreshMaterials|true|false|false p1 = >>73-0<< p1 = >>__vz<< p1 = >>refreshMaterials<< p1 = >>true<< p1 = >>false<< p1 = >>false<< calling function >>refreshMaterials<< String Time = 6.0e-05 Total Entities = 1
                    I changed the js and the ruby ¶ into |

                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                    1 條回覆 最後回覆 回覆 引用 0
                    • D 離線
                      driven
                      最後由 編輯

                      next error... !!!=> fromUIHandler: parameter string = 73-0|__vE|findComponents|·147713020 p1 = >>73-0<< p1 = >>__vE<< p1 = >>findComponents<< p1 = >>·147713020<< calling function >>findComponents<< Error: #<ArgumentError: invalid value for Integer: "·147713020">

                      learn from the mistakes of others, you may not live long enough to make them all yourself...

                      1 條回覆 最後回覆 回覆 引用 0
                      • M 離線
                        Myhand
                        最後由 編輯

                        @driven said:

                        next error... !!!=> fromUIHandler: parameter string = 73-0|__vE|findComponents|·147713020 p1 = >>73-0<< p1 = >>__vE<< p1 = >>findComponents<< p1 = >>·147713020<< calling function >>findComponents<< Error: #<ArgumentError: invalid value for Integer: "·147713020">

                        Good work! This one is because the "·" char (183) char is used as an array token, and is also passed as a double byte char. So you would need to change that also.

                        BTW, I have just seen that the debug.rbz I attached earlier was not built properly. So it might well be that the fix I put in earlier will work, but I cannot get the build to work yet.

                        Appologies for wasting your time with testing that version! 😳

                        http://www.keepingmyhandin.com/

                        1 條回覆 最後回覆 回覆 引用 0
                        • thomthomT 離線
                          thomthom
                          最後由 編輯

                          @myhand said:

                          @thomthom said:

                          SketchUp return strings in UTF-8. Anything above the ASCII character range will be multi-byte characters - which is easily mangled by Ruby 1.8's string manipulation methods as it treats 'characters' as single bytes.

                          But my characters are well within the ASCII range...? i.e. they still fit within a byte. from which value does it convert them to multi byte?

                          You seem to be using the ANSI range - you use bytes 182 and 183 which is not ASCII.
                          ASCII is just 0-127 - while ANSI is a sub-set that extends that with 128-255.

                          UTF-8 matches the ASCII character encoding - but does not match ANSI. In UTF-8 bytes 128-255 are control characters. So when you feed a UTF-8 system (like SketchUp) ANSI strings you get messed up characters.

                          ¶ encoded in UTF-8 is [194, 182] - which is why when you split by just 182 you get the extra 194 byte ( Â).

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

                          1 條回覆 最後回覆 回覆 引用 0
                          • thomthomT 離線
                            thomthom
                            最後由 編輯

                            When I send parameters back from WebDialogs I've used combo characters like || or ||| which I know is very unlikely to appear in the data I send. (In the context of what I've done I've been sure they'd not appear.)

                            In a system where there is user input you'd want to create your own escape sequence where you pick a character as array separator and ensure to escape any occurrence in the data - which then is un-escaped when you receive it on the other end.

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

                            1 條回覆 最後回覆 回覆 引用 0
                            • TIGT 離線
                              TIG Moderator
                              最後由 編輯

                              Another way is to restrict what a user can enter - e.g.
                              <input type="text" id="project_name" value="" style="font-size:7pt; width:300px;" onKeyup="(this.value=this.value.replace(/[^-_0-9A-Za-z]/,''));" ... >
                              This example limits the user's INPUT for the 'project_name' to letters, numbers, _, - etc... Then you can be sure that any 'separator' like '|' won't get replicated in the entered text... Obviously you need to change the regexp to suit your needs...

                              TIG

                              1 條回覆 最後回覆 回覆 引用 0
                              • M 離線
                                Myhand
                                最後由 編輯

                                @tig said:

                                Another way is to restrict what a user can enter - e.g.
                                <input type="text" id="project_name" value="" style="font-size:7pt; width:300px;" onKeyup="(this.value=this.value.replace(/[^-_0-9A-Za-z]/,''));" ... >
                                This example limits the user's INPUT for the 'project_name' to letters, numbers, _, - etc... Then you can be sure that any 'separator' like '|' won't get replicated in the entered text... Obviously you need to change the regexp to suit your needs...

                                yes I agree you always want to constrain at the input. In this case though the input in question is the Sketchup material editor, so I unfortunately have no control over that input.

                                http://www.keepingmyhandin.com/

                                1 條回覆 最後回覆 回覆 引用 0
                                • M 離線
                                  Myhand
                                  最後由 編輯

                                  @thomthom said:

                                  When I send parameters back from WebDialogs I've used combo characters like || or ||| which I know is very unlikely to appear in the data I send. (In the context of what I've done I've been sure they'd not appear.)

                                  In a system where there is user input you'd want to create your own escape sequence where you pick a character as array separator and ensure to escape any occurrence in the data - which then is un-escaped when you receive it on the other end.

                                  Escaping is the best way, and also what I am using in my Simple Jason serializer. I'll probably just implement the de-serialiser and then this whole problem will go away.

                                  Your short cut of using ||| etc. is also a good option and I will probably use that in the short term if my latest attempt to fix the problem does not work.

                                  http://www.keepingmyhandin.com/

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • M 離線
                                    Myhand
                                    最後由 編輯

                                    John, CMD, do you mind testing the attached version please?

                                    The previous debug version did not change the JS code as I thought it did. This one does. It is the last try with the current control chars, and if this does not work I will create a patch with a multiple chars in the standard ascii range.

                                    Again this requires a uninstall of the old plugin, restart of Sketchup and a install of the new debug version.

                                    Again please send me the output.

                                    Debug version

                                    http://www.keepingmyhandin.com/

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • D 離線
                                      driven
                                      最後由 編輯

                                      same problem p1 = >>73-0Â<<

                                      learn from the mistakes of others, you may not live long enough to make them all yourself...

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • thomthomT 離線
                                        thomthom
                                        最後由 編輯

                                        You replaced teh character with String.fromCharCode(183) ?
                                        And from what Driven says, that didn´t work either.

                                        Why don´t you just split the param string with the proper UTF-8 sequence? You are after all dealing with UTF-8 within SketchUp - and also from the WebDialog. So to ensure you avoid encoding problems, which you have right now, just consistently treat everything as UTF-8. If you go back to where you had ¶ in your JS all you need to do is split the param string by the byte by the UTF-8 sequency 194, 182.

                                        Trying to force it through a different encoding, in this case ANSI, is just asking for problems.

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

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • thomthomT 離線
                                          thomthom
                                          最後由 編輯

                                          Btw, did you see my comment at the end of the prevous page regarding ASCII vs ANSI vs UTF-8? (Not sure if you missed it, as my last comment will make less sense if you missed it.)
                                          http://sketchucation.com/forums/viewtopic.php?f=323&t=48933&start=45#p442858

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

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • M 離線
                                            Myhand
                                            最後由 編輯

                                            Thank you everyone for your help and good advice. Here is a version with noth of the protocol chars in the normal ascii range. I have chosen 30, and 31 the record and unit separator characters. They are not printable so there is a small chance there might again be problems on the MAC I guess, but this works fine on Windows.

                                            John, CMD do you mind trying again please? Debug is still on, so if this works I will publish a version without the tracing code.

                                            Debug version

                                            http://www.keepingmyhandin.com/

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 8
                                            • 5 / 8
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement