sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

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

    Scheduled Pinned Locked Moved Plugins
    155 Posts 19 Posters 49.5k Views 19 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.
    • thomthomT Offline
      thomthom
      last edited by

      hm... the error is a missing refreshMaterial method - how can that be OSX specific?

      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

        @thomthom said:

        hm... the error is a missing refreshMaterial method - how can that be OSX specific?

        I pass the method name in from javascript... the method certainly is there, and this code works on Windows... So somehow it does not resolve in this case.

        So as far as I can see: either the method name coming in from JS (I assume the webdialog run in Safari on OSX) is somehow corrupted - how I do not know or I am not using the robust RUBY syntax in defining the method, and Ruby on OSX cannot find it.

        For instance should I pre-pend it with "self". I do not know and cannot debug as I do not have OSX.

        Has anyone else had this problem in windows, or got it working in OSX?

        http://www.keepingmyhandin.com/

        1 Reply Last reply Reply Quote 0
        • M Offline
          Myhand
          last edited by

          cmd, I have done some experiments and suspect you may have a corrupt installation.

          You can either:

          • fully delete the plugin. The whole ..\Plugins\Material_Maintenance folder. And the reinstall and see if you still get the problem

          • open your ..\Plugins\Material_Maintenance\Material_Maintenance.rb file in a text editor and see if on line 150 you have the following method definition:

            def refreshMaterials(selectionOnly, wholeModel, components)

          • send me the ..\Plugins\Material_Maintenance\Material_Maintenance.rb file

          http://www.keepingmyhandin.com/

          1 Reply Last reply Reply Quote 0
          • cmdC Offline
            cmd
            last edited by

            @myhand said:

            • open your ..\Plugins\Material_Maintenance\Material_Maintenance.rb file in a text editor and see if on line 150 you have the following method definition:

              def refreshMaterials(selectionOnly, wholeModel, components)

            I have looked into the file and I have found the required "refreshMaterials" definition.

            Regardless, I will test it out on my windows system through parallels and let you know what I find.

            CMD

            • CMD
            1 Reply Last reply Reply Quote 0
            • M Offline
              Myhand
              last edited by

              @cmd said:

              I have looked into the file and I have found the required "refreshMaterials" definition.

              Regardless, I will test it out on my windows system through parallels and let you know what I find.

              CMD

              Thanks CMD, that will be very useful. I hate not being able to debug it myself!

              http://www.keepingmyhandin.com/

              1 Reply Last reply Reply Quote 0
              • M Offline
                Myhand
                last edited by

                @thomthom said:

                I've got a bridge in development in my TT_Lib2 library: http://www.thomthom.net/software/sketchup/tt_lib2/doc/
                A JSON sub-class of a Hash and a bridge where I can call JS functions just with their name from Ruby and it will convert many types of objects to JS object and the return value of the JS function will be converted back into Ruby objects. Got most of the basic data types working and some of SU's custom classes, such as Vector3d and Point3d.
                https://bitbucket.org/thomthom/tt-library-2/

                Parallel to that there's a WebDialog bridge developed in SketchUp's Developer Tools they released as Open Source at last Basecamp: https://github.com/SketchUp/sketchup-developer-tools

                You could have a look at either repos if it could help you.

                It would have been interesting to create a standalone bridge as an open source project, avoiding each developer to create their own version.

                Thank you thomthom, very impressive library! ๐Ÿ‘ A shame I did not know about it before I started.

                Unfortunately I already developed a basic bridge so changing it now would be more work than just adding a JSON marshal class. I wrote a basic one in ruby (so probably not the most efficient but works fine for the size of objects I want to pass). Does all objects, and escapes special characters etc. and does the trick for now. I will publish the code a bit later if anyone is interested. As all of my complex objects go from ruby to JS I have not written a parser (yet).

                You have some experience with the C++ API. Does that give access to more attributes than the Ruby API. Specifically I want to change the material assigned to layers.

                http://www.keepingmyhandin.com/

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  @myhand said:

                  You have some experience with the C++ API. Does that give access to more attributes than the Ruby API. Specifically I want to change the material assigned to layers.

                  The C++ SDK for for reading and writing files. It's not something you can use from within SketchUp - manipulate the active model.
                  But if your goal it to generate a SKP file, then it might be the thing for you. However, I've not used it.

                  Regarding the Bridge - we talked about this at Basecamp (2012). I think the topic has potential for an Open Source project. We're currently testing out the experience of open source group projects with the STL Importer/Exporter and the Development Tools that SketchUp released. I'd like to see a bridge project established - and even more projects - so we can avoid redoing the work which the next man already have done.

                  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

                    For anyone interested here is a link to the JSON formatter class I created. I am now using this for the next version of this plugin, which will allow you to pick a component and find its parent hierarchy. i.e. components containing nested instances of the specified component.

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

                    http://www.keepingmyhandin.com/

                    1 Reply Last reply Reply Quote 0
                    • cmdC Offline
                      cmd
                      last edited by

                      @myhand said:

                      Thanks CMD, that will be very useful. I hate not being able to debug it myself!

                      Myhand,

                      I installed the script on my windows version and all worked fine.

                      I also removed and reinstalled it on my Mac but I am getting the same error on launch of the script ๐Ÿ˜ž

                      @unknownuser said:

                      Error: #<NoMethodError: undefined method `refreshMaterials' for #<MH_KeepingMyHandIn::MaterialMaintenance:0x15306b40>>

                      CMD

                      • CMD
                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        Myhand
                        last edited by

                        @cmd said:

                        @myhand said:

                        Thanks CMD, that will be very useful. I hate not being able to debug it myself!

                        Myhand,

                        I installed the script on my windows version and all worked fine.

                        I also removed and reinstalled it on my Mac but I am getting the same error on launch of the script ๐Ÿ˜ž

                        @unknownuser said:

                        Error: #<NoMethodError: undefined method `refreshMaterials' for #<MH_KeepingMyHandIn::MaterialMaintenance:0x15306b40>>

                        CMD

                        Thanks CMD, sounds like my hunch might have been right and that it is something to do with the MAC.

                        Can anyone that has used the script on a MAC (successfully or otherwise) please let me know?

                        Else we might have to do this the hard way... CMD, if I add some debug code to the script would you mind running it and sending me the output?

                        Cheers,

                        myhand

                        http://www.keepingmyhandin.com/

                        1 Reply Last reply Reply Quote 0
                        • R Offline
                          rv1974
                          last edited by

                          Myhand, let me shake your hand!
                          this is a real helper (especially for those who render outside SU and care about mats order).
                          Thank you!

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            Myhand
                            last edited by

                            @rv1974 said:

                            Myhand, let me shake your hand!
                            this is a real helper (especially for those who render outside SU and care about mats order).
                            Thank you!

                            ๐Ÿ˜„ Glad you like it!

                            http://www.keepingmyhandin.com/

                            1 Reply Last reply Reply Quote 0
                            • cmdC Offline
                              cmd
                              last edited by

                              @myhand said:

                              ... CMD, if I add some debug code to the script would you mind running it and sending me the output?

                              No problem ๐Ÿ˜„

                              CMD

                              • CMD
                              1 Reply Last reply Reply Quote 0
                              • M Offline
                                Myhand
                                last edited by

                                @cmd said:

                                @myhand said:

                                ... CMD, if I add some debug code to the script would you mind running it and sending me the output?

                                No problem ๐Ÿ˜„

                                CMD

                                Hi CMD,

                                here is the file

                                Debug version

                                You can replace the Material_Maintenance.rb file in your ../Plugins/Material_Maintenance folder, restart sketchup, open the console window and launch the plugin. The script will output some debug to the console. Can you send me the whole console output please.

                                Cheers,

                                myhand

                                http://www.keepingmyhandin.com/

                                1 Reply Last reply Reply Quote 0
                                • cmdC Offline
                                  cmd
                                  last edited by

                                  Here is the output from the ruby console after replacing with your posted Material_Maintenance.rb and launching the tool.

                                  CMD


                                  ruby console output.txt

                                  • CMD
                                  1 Reply Last reply Reply Quote 0
                                  • J Offline
                                    Jim
                                    last edited by

                                    You may need to move the method definition of fromUIHandler to after the definition of refreshMaterials. Ruby might be trying to call refreshMaterials

                                      ` results = self.send(targetFunction.to_sym, *params)`
                                    

                                    before it is defined.

                                    I sent a PM.

                                    Hi

                                    1 Reply Last reply Reply Quote 0
                                    • M Offline
                                      Myhand
                                      last edited by

                                      @cmd said:

                                      Here is the output from the ruby console after replacing with your posted Material_Maintenance.rb and launching the tool.

                                      CMD

                                      Thanks CMD.

                                      Unfortunately the attached output implies that the debug version of the Material_Maintenance.rb script did not run but rather the old version.

                                      the error says:

                                      
                                      Error; #<NoMethodError; undefined method `refreshMaterials' for #<MH_KeepingMyHandIn;;MaterialMaintenance;0x1383e920>>
                                      /Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb;106;in `send'
                                      
                                      

                                      and indicates the send method call is on line 106, while it is actually on line 122 in the debug version.

                                      Have you restarted Sketchup after copying the new file in?

                                      A few ways to check that the debug script is running are:

                                      • You should see this message in the console: "calling function >>refreshMaterials<<"; There might also be the same message but with other function names
                                      • The the above error appears again, it should be on line 122 not line 106.

                                      Cheers,

                                      myhand

                                      http://www.keepingmyhandin.com/

                                      1 Reply Last reply Reply Quote 0
                                      • cmdC Offline
                                        cmd
                                        last edited by

                                        sorry about that.

                                        Unfortunately, here is what I get with your debug .rb


                                        Screen Shot 2012-11-29 at 3.26.15 PM.png

                                        • CMD
                                        1 Reply Last reply Reply Quote 0
                                        • D Offline
                                          driven
                                          last edited by

                                          I get this with ruby 1.8.5 or ruby 1.8.7

                                          Error: #<NoMethodError: undefined methodto_sym' for nil:NilClass>
                                          /Users/johns_iMac/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb:106:in fromUIHandler' /Users/johns_iMac/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb:66:in initialise'
                                          /Users/johns_iMac/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb:106:in call' /Users/johns_iMac/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/Material_Maintenance/Material_Maintenance.rb:106
                                          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
                                          • cmdC Offline
                                            cmd
                                            last edited by

                                            Myhand,

                                            Sorry.. I replaced the wrong file. Here is what I get in the Ruby console with your debug script after I launch the tool.

                                            @unknownuser said:

                                            calling function >>refreshMaterialsร‚<<
                                            !!!!! - IN refreshMaterials !!!!!
                                            String Time = 3.0e-06
                                            Total Entities = 0

                                            I hope this helps

                                            CMD

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

                                            Advertisement