• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

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

Scheduled Pinned Locked Moved Plugins
155 Posts 19 Posters 49.5k Views
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.
  • T Offline
    thomthom
    last edited by 1 Dec 2012, 10:53

    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 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 1 Dec 2012, 11:25

      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 Reply Last reply Reply Quote 0
      • M Offline
        Myhand
        last edited by 1 Dec 2012, 14:50

        @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 Reply Last reply Reply Quote 0
        • M Offline
          Myhand
          last edited by 1 Dec 2012, 15:05

          @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 Reply Last reply Reply Quote 0
          • M Offline
            Myhand
            last edited by 1 Dec 2012, 15:17

            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 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by 1 Dec 2012, 17:01

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

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

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 1 Dec 2012, 17:16

                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 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 1 Dec 2012, 17:19

                  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 Reply Last reply Reply Quote 0
                  • M Offline
                    Myhand
                    last edited by 1 Dec 2012, 19:21

                    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 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by 2 Dec 2012, 00:22

                      the good news is

                      # SU returns  =>
                       RUBY_VERSION = 1.8.5
                      (eval);3119; warning; parenthesize argument(s) for future version
                      (eval);3142; warning; parenthesize argument(s) for future version
                      key = Units
                      value = 0.0
                      key = StampOffset
                      value = 12.0
                      key = GridSpacingX
                      value = 120.0
                      key = SmooveRadius
                      value = 360.0
                      key = GridSpacingY
                      value = 120.0
                      !!!=> fromUIHandler; parameter string = 73-0__vzrefreshMaterialstruefalsefalse
                      p1 = >>73-0<<
                      p1 = >>__vz<<
                      p1 = >>refreshMaterials<<
                      p1 = >>true<<
                      p1 = >>false<<
                      p1 = >>false<<
                      calling function >>refreshMaterials<<
                      String Time = 5.9e-05
                      Total Entities = 1
                      
                      
                      # SU returns  =>
                       RUBY_VERSION = 1.8.7
                      key = Units
                      value = 0.0
                      !!!=> fromUIHandler; parameter string = 73-0__vzrefreshMaterialstruefalsefalse
                      p1 = >>73-0<<
                      p1 = >>__vz<<
                      p1 = >>refreshMaterials<<
                      p1 = >>true<<
                      p1 = >>false<<
                      p1 = >>false<<
                      calling function >>refreshMaterials<<
                      String Time = 6.4e-05
                      

                      seems to work with either RUBY_VERSION, but the verbosity level is higher in 1.8.5
                      john

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

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        cmd
                        last edited by 2 Dec 2012, 03:57

                        @myhand said:

                        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.

                        Myhand,

                        Attached is the output immediately after launching the Material Maintenance plugin.

                        CMD


                        MM_Ruby output.txt

                        • CMD
                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          TIG Moderator
                          last edited by 2 Dec 2012, 11:17

                          The text file when opened in 'Notepad++.exe' as 'UTF-8 without BOM' shows this: Capture.PNG BUT when the same text is pasted into here it displays differently...
                          !!!=> fromUIHandler: parameter string = 73-0__vzrefreshMaterialstruefalsefalse Error: #<NoMethodError: private methodputs' called for "73-0":String>`
                          Presumably the 'RS' record-separator character [ASCII-030] is non-printing...
                          Not sure how 'puts' seems broken 😕
                          Are you parsing the string using split and the 'RS' as at splitter ?
                          You should then be able to 'puts' the array elements ??

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            Myhand
                            last edited by 2 Dec 2012, 13:31

                            @tig said:

                            The text file when opened in 'Notepad++.exe' as 'UTF-8 without BOM' shows this: [attachment=0:2y0lvhlv]<!-- ia0 -->Capture.PNG<!-- ia0 -->[/attachment:2y0lvhlv] BUT when the same text is pasted into here it displays differently...
                            !!!=> fromUIHandler: parameter string = 73-0__vzrefreshMaterialstruefalsefalse Error: #<NoMethodError: private methodputs' called for "73-0":String>`
                            Presumably the 'RS' record-separator character [ASCII-030] is non-printing...
                            Not sure how 'puts' seems broken 😕
                            Are you parsing the string using split and the 'RS' as at splitter ?
                            You should then be able to 'puts' the array elements ??

                            Yes I am splitting the string with the 'RS' char. Very strange error message indeed. The code snippet where it fails is:

                            ` puts "!!!=> fromUIHandler: parameter string = #{parameterString}";

                              params = unmarshalParams(parameterString);
                              
                              params.each { |p|
                                p.puts "p1 = >>#{p}<<";   // This is line 109
                              }`
                            

                            Again this works fine on Windows, and appears to now also work for driven on his MAC so at a bit of a loss here.

                            One other strange thing with this is that the output should look like this:

                            
                            !!!=> fromUIHandler; parameter string = 75-0__materialsRefreshedrefreshMaterialstruefalsefalse
                            p1 = >>75-0<<
                            p1 = >>__materialsRefreshed<<
                            p1 = >>refreshMaterials<<
                            p1 = >>true<<
                            p1 = >>false<<
                            p1 = >>false<<
                            calling function >>refreshMaterials<<
                            
                            

                            i.e. the second parameter should be "__materialsRefreshed" not "__vz" which it appears to be for both the MAC implementations. Strictly speaking this should not work even for driven.

                            CMD, are you sure you have done a clean uninstall and install?

                            http://www.keepingmyhandin.com/

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              TIG Moderator
                              last edited by 2 Dec 2012, 13:37

                              But params.each{|p|puts "p1 = >>#{p}<<"}
                              should be the way ?
                              NOT p.puts

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • M Offline
                                Myhand
                                last edited by 2 Dec 2012, 14:08

                                @tig said:

                                But params.each{|p|puts "p1 = >>#{p}<<"}
                                should be the way ?
                                NOT p.puts

                                😳 thanks TIG!

                                Still strange it worked on windows and driven's MAC and that the second parameter comes looks wrong but as long as it works.

                                I am making a new build without the trace code which I will upload soon.

                                http://www.keepingmyhandin.com/

                                1 Reply Last reply Reply Quote 0
                                • M Offline
                                  Myhand
                                  last edited by 2 Dec 2012, 14:19

                                  Bug fix version V2.1.1 released.

                                  Can be found here:

                                  http://www.keepingmyhandin.com/Downhome/Sketchup/material_maintenance_2

                                  CMD this should fix your problem also as the trace code that had the bug in is also now removed.

                                  http://www.keepingmyhandin.com/

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    Tpdart
                                    last edited by 3 Dec 2012, 11:07

                                    It may be me, but I've put the .rbz in the plugins folder, restarted SU but I cannot find the command or interface. Any thoughts?

                                    Thanks!

                                    1 Reply Last reply Reply Quote 0
                                    • G Offline
                                      Gaieus
                                      last edited by 3 Dec 2012, 11:21

                                      You do not use an RBZ file like that. Please, read this tutorial on installing plugins:
                                      http://sketchucation.com/resources/tutorials/37-beginner/108-installing-sketchup-plugins

                                      Gai...

                                      1 Reply Last reply Reply Quote 0
                                      • T Offline
                                        Tpdart
                                        last edited by 3 Dec 2012, 11:40

                                        DOH!
                                        I didn't install the extension- once I PROPERLY followed the instructions it looks great I can't wait to try it out on an inherited complex model with many similar materials.

                                        1 Reply Last reply Reply Quote 0
                                        • C Offline
                                          cmd
                                          last edited by 3 Dec 2012, 14:16

                                          @myhand said:

                                          Bug fix version V2.1.1 released.

                                          ... CMD this should fix your problem also as the trace code that had the bug in is also now removed.

                                          Myhand,

                                          Good stuff! no more errors!

                                          .... but I am not getting material thumbnails nor am I getting component images to display.

                                          Is this due to the change for mac?


                                          Screen Shot 2012-12-03 at 7.16.11 AM.png

                                          • CMD
                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 3
                                          • 4
                                          • 5
                                          • 6
                                          • 7
                                          • 8
                                          • 4 / 8
                                          4 / 8
                                          • First post
                                            74/155
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement