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.
    • M Offline
      Myhand
      last edited by

      @tig said:

      How are you to show the display-name AND its matching thumbnail in the dialog etc ? Unless you have both to refer to ?

      I pass in both the name(as is without any manipulation), and the object_id to the WebDialog. This also allows me to uniquely identify which materials to change. i.e. I only pass the object_id (key) back to Ruby.

      http://www.keepingmyhandin.com/

      1 Reply Last reply Reply Quote 0
      • A Offline
        archtrot
        last edited by

        Great plugin...I've needed something like this for a long time.
        The labels on the UI are getting reduced, regardless of window size.
        See attached image. Any idea why this is?
        I'm SU8 on Windows 7.


        SP32-20121204-170122.jpg

        1 Reply Last reply Reply Quote 0
        • B Offline
          ByKAz
          last edited by

          Sorry but it didn't work to me...
          Any Update!?!?!


          Screen Shot 2012-12-05 at 1.02.01 AM.png

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

            Looks more like an issue with SketchUp's installer feature... Can you install other plugins without problems?

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

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              Are you trying to install this RBZ file from a location on your computer - not the Internet πŸ˜•

              Do you have read AND write access to the 'plugins' folder?
              NOT the 'user' one, BUT the main one in the HD folder tree...
              If not then you can't auto-add files like this...

              TIG

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

                [mod=Split topic:1mb3nheb]Split of the last few posts into a separate topic: http://sketchucation.com/forums/viewtopic.php?f=180&t=49354
                Related to using object ids for retrieving object instances.[/mod:1mb3nheb]

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

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  How about this different approach.
                  Avoiding worrying about 'id' etc...

                  You assemble a collection of every material display_name and name, sorted ['matnames'].
                  matnames=[]; model.materials.each{|m|matnames << [m.display_name.gsub(/[/\\?%*:|"<>.,']/, ''), m.name]} matnames.sort!

                  You decide on what to gsub out etc...

                  You then iterate that array to make another array of those materials ['mats'].
                  mats=[]; matnames.each{|a|mats << model.materials[a[1]]}

                  a[1] is the material's name used to access the material reference.

                  At this point each index in the two arrays' point at a display_name (as a[0]) and its matching material.
                  Now make the thumbnail images.
                  matthumbs=[]; mats.each_with_index{|m, i|p=File.join(tempfolderpath, i.to_s+'.png'); matthumbs << p; m.write_thumbnail(p, 128)}

                  AFTER all of the assembly, you might also want to thinkabout the '<Default>' material and always have that as item 0 in each array; e.g.

                  mathames=[['<Default>']]+matnames mats=[nil]+mats matthumbs=[pathToDefaultThumbnailPNGinMMsubfolder]+matthumbs
                  ###I suggest that you make a standard PNG, unless you want to create one based on the real two default-materials' colors got from:
                  model.rendering_options["FaceFrontColor"] model.rendering_options["FaceBackColor"]
                  You can then write the PNG's [or BMP file] bits etc using those color's RGB values to match... [I think that thomthom has some snippets on that - try bitmap2mesh etc al - there's also some good stuff here https://practicingruby.com/articles/shared/oelhlibhtlkx ]

                  You now have three arrays of various 'matching' things to do with the SKP's materials, using the same indexing regime...

                  Now... you assemble the materials list for the dialog...
                  For example, the item under the dialog's index ' **3**', has a 'name' text-string taken from the matching matnames[**3**][0], and it displays the matching thumbnail-image matthubs[**3**], and that same index then used in mats[**3**] is the actual SKP material to be used when the Ruby does the changing, swapping etc... Because the item's 'index' is a simple integer, then converting to and then from a string, is straightforward in a 'callback', or whatever you use...

                  The same ideas would also apply to the 'component-definitions' - the only addition would be to separate the thumbnail images use say i.to_s+'**x**.png' for the components...

                  TIG

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

                    @cmd said:

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

                    Sorry this took so long but have been in the middle of something else. Here is a debug version that will trace the file paths the Javascript code is trying to load into the ruby console. Same install procedure as before.

                    Please send me the console output.

                    Thumbnail debug

                    http://www.keepingmyhandin.com/

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

                      broken again value = 0.0 !!!=> fromUIHandler: parameter string = 73-0__vzrefreshMaterialstruefalsefalse Error: #<NoMethodError: private methodputs' called for "73-0":String>`

                      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
                      • M Offline
                        Myhand
                        last edited by

                        @driven said:

                        broken again value = 0.0 !!!=> fromUIHandler: parameter string = 73-0__vzrefreshMaterialstruefalsefalse Error: #<NoMethodError: private methodputs' called for "73-0":String>`

                        john

                        Hi John, I suspect you have installed an older version. I have just rechecked the Material_Maintenance_thumbnail_dbg_01.rbz file (you can unzip it) and the above two puts have been commented out. You can check by looking at lines 106 and 111 in the Material_Maintenance/Material_Maintenance.rb file within the .rbz archive.

                        http://www.keepingmyhandin.com/

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

                          @myhand said:

                          Hi John, I suspect you have installed an older version.

                          I used the SU installer to overwrite the old, but probably hit 'don't trust' in the setup dialog....
                          fresh instal
                          String Time = 6.0e-06 Total Entities = 0 null/Material2_150652410.png?1 String Time = 0.012297 Total Entities = 1063 null/Material2_150652410.png?2 String Time = 0.00685

                          I can help debug the images if you stop the width of you generated content autoresizing. or just PM instructions of where it's set so I can get a hook in for Web Inspector to check the paths.

                          BTW: I and Sketchup use ./tmp/* for temp file on mac, it's so simple....
                          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
                          • M Offline
                            Myhand
                            last edited by

                            @driven said:

                            @myhand said:

                            Hi John, I suspect you have installed an older version.

                            I used the SU installer to overwrite the old, but probably hit 'don't trust' in the setup dialog....
                            fresh instal
                            String Time = 6.0e-06 Total Entities = 0 null/Material2_150652410.png?1 String Time = 0.012297 Total Entities = 1063 null/Material2_150652410.png?2 String Time = 0.00685

                            Very interesting. I will add some more trace tonight. All the way through the call stack this time.

                            @driven said:

                            @myhand said:

                            I can help debug the images if you stop the width of you generated content autoresizing. or just PM instructions of where it's set so I can get a hook in for Web Inspector to check the paths.

                            I use a JS library called qooxdoo. So I cannot just change the HTML as all the html is generated and the "container" locks it down. So I need to figure out how do it through library. I tried a few minutes to manipulate the HTML directly which did not work. Will take another look tonight.

                            @driven said:

                            @myhand said:

                            BTW: I and Sketchup use ./tmp/* for temp file on mac, it's so simple....
                            john

                            Is there a reliable way to determine OS in Ruby then I can change temp directory to the above when run on a MAC?

                            http://www.keepingmyhandin.com/

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

                              my personal favourite [from SU's WebTextures]
                              # PC Load paths will have a ':' after the drive letter. @is_mac = ($LOAD_PATH[0][1..1] != ":")

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

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

                                @archtrot said:

                                Great plugin...I've needed something like this for a long time.
                                The labels on the UI are getting reduced, regardless of window size.
                                See attached image. Any idea why this is?
                                I'm SU8 on Windows 7.

                                I tried to reproduce this on one of my Windows 7 machines but the labels look fine. Which version of IE are you on?

                                Has anyone else seen this problem?

                                http://www.keepingmyhandin.com/

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

                                  @driven said:

                                  my personal favourite [from SU's WebTextures]
                                  # PC Load paths will have a ':' after the drive letter. @is_mac = ($LOAD_PATH[0][1..1] != ":")

                                  Ok thanks, I will try this next but would still like to see where the current version goes wrong. Do you mind testing the attached and sending me all the output again please?

                                  Debug version

                                  http://www.keepingmyhandin.com/

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

                                    seems to work, but I don't really use materials much, things like 'components that use this' are coming in blank, but that may be my test models fault. want to post a good working sample skp...
                                    tempPath = /var/folders/rp/b9k42l5x7xngx_8tckgs0zdr0000gn/T @tempDir = /var/folders/rp/b9k42l5x7xngx_8tckgs0zdr0000gn/T/material_maintenance /var/folders/rp/b9k42l5x7xngx_8tckgs0zdr0000gn/T/material_maintenance exists!!! String Time = 0.040138 Total Entities = 3291 UI => null/[Translucent_Glass_Blue] copy_147939200.png?1 String Time = 0.053043 Total Entities = 3291 UI => null/[Translucent_Glass_Blue] copy_148426790.png?4

                                    I also did a test and the images show in SU using set html and that path, there very small though...

                                    
                                    > dlg2 = UI;;WebDialog.new("it works again2", true,"img", 250, 250, 400, 150, true);
                                    dlg2.set_html(%q(<img src="file;////private/var/folders/rp/b9k42l5x7xngx_8tckgs0zdr0000gn/T/material_maintenance/Cladding_Siding_White_148435700.png" alt="test image" title="my test2" >))
                                    dlg2.show_modal
                                    true
                                    

                                    also I should be promoting the Boolean darwin version check

                                    # this is mac only!
                                    if( !( RUBY_PLATFORM =~ /darwin/i) )
                                      UI.messagebox("This code is for Mac only!")
                                    

                                    but which ever you choose add .show_modal as one off you mac conditionals...

                                    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 said:

                                      Ok thanks, I will try this next but would still like to see where the current version goes wrong. Do you mind testing the attached and sending me all the output again please?

                                      Myhand,

                                      Here is the ruby console output on launch of your latest MM_debug ruby:

                                      tempPath = /var/folders/jt/x_n2z5n109n9v_qfj562bsc87bn_mb/T
                                      @tempDir = /var/folders/jt/x_n2z5n109n9v_qfj562bsc87bn_mb/T/material_maintenance
                                      /var/folders/jt/x_n2z5n109n9v_qfj562bsc87bn_mb/T/material_maintenance exists!!!
                                      String Time = 4.0e-06
                                      Total Entities = 0
                                      UI => null/jean blue_173796570.png?1

                                      Here is the output after Component option=checked + RE-LOAD Materials section

                                      String Time = 0.006283
                                      Total Entities = 485
                                      UI => null/jean blue_173786390.png?2

                                      Here is the output after a material from list is selected and List Components Containing Selected Materials is activated

                                      UI => Temp dir = null

                                      Screen Shot 2012-12-07 at 7.32.51 PM.png
                                      I hope this helps

                                      CMD

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

                                        @driven said:

                                        but which ever you choose add .show_modal as one off you mac conditionals...

                                        Are you sugesting I make the WebDialog modal? I have not set it as modal as I keep it open while working in the model. I flip between the model and the dialog often while cleaning up a model.

                                        http://www.keepingmyhandin.com/

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

                                          @myhand said:

                                          Are you sugesting I make the WebDialog modal?

                                          modal is different on a mac. lots of reference available via search πŸ˜‰

                                          but you'll want a conditional for mac
                                          if mac dlg.show_modal else show end
                                          then it doesn't vanish on us...
                                          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
                                          • M Offline
                                            Myhand
                                            last edited by

                                            @driven said:

                                            @myhand said:

                                            Are you sugesting I make the WebDialog modal?

                                            modal is different on a mac. lots of reference available via search πŸ˜‰

                                            but you'll want a conditional for mac
                                            if mac dlg.show_modal else show end
                                            then it doesn't vanish on us...
                                            john

                                            OK thanks John. Will add it to the next bugfix release. Hopefully soon, if we can get the thumb problem sorted!

                                            http://www.keepingmyhandin.com/

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

                                            Advertisement