• Login
sketchucation logo sketchucation
  • Login
🤑 30% Off | Artisan 2 on sale until April 30th Buy Now

[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.
  • M Offline
    Myhand
    last edited by 3 Dec 2012, 21:19

    @oxer said:

    I have the same problem like cmd, the material thumbnails don't appear, I work on Mac OSX.

    Can you please follow TIG's instructions below and let us know the results?

    @tig said:

    @cmd
    If you write this in the Ruby Console ENV['TMPDIR'] + <enter> it gives the path to your 'temp' folder.
    In that folder ought to be a subfolder named 'material_maintenance' and in that the xxx.png material thumbnails and xxx.comp.png component thumbnails ? They might have weird looking 'id' type names...
    The subfolder is emptied when the tool runs, or it's made if it is missing.
    It could be that the files are getting made but some enduring issue in the html/js on MAC is preventing them displaying ??
    Can you confirm if the subfolder/files exist...

    Can you also please run

    ENV.sort.each{|e|p e};p

    and attach the console output.

    http://www.keepingmyhandin.com/

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

      @myhand said:

      @tig said:

      Can you confirm if the subfolder/files exist...

      Myhand & TIG

      Yes... the folders and image files do exist.

      CMD


      Screen Shot 2012-12-03 at 4.14.37 PM.png

      • CMD
      1 Reply Last reply Reply Quote 0
      • C Offline
        cmd
        last edited by 3 Dec 2012, 23:17

        @unknownuser said:

        Can you also please run

        ENV.sort.each{|e|p e};p

        and attach the console output.


        Screen Shot 2012-12-03 at 4.04.08 PM.png

        • CMD
        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 4 Dec 2012, 09:35

          So the folder/subfolder is OK and the images exist.

          The image naming seems unduly convoluted, as it's adding some special characters etc...
          Why not use each material.display_name [with some replacement of characters like \ / : * ? " < > | etc] linked to a hash of the display-name containing its 'id' ?
          The thumbnail-images names match the 'display-names' ?

          TIG

          1 Reply Last reply Reply Quote 0
          • M Offline
            Myhand
            last edited by 4 Dec 2012, 11:52

            @tig said:

            So the folder/subfolder is OK and the images exist.

            The image naming seems unduly convoluted, as it's adding some special characters etc...
            Why not use each material.display_name [with some replacement of characters like \ / : * ? " < > | etc] linked to a hash of the display-name containing its 'id' ?
            The thumbnail-images names match the 'display-names' ?

            This is sort of what I have done. i.e.

            display_name + "_" + object_id + ".png"

            with invalid windows file name characters replaced with the ¶ character. I know this character caused us problems in the marshaling on OSX, but forgot to remove it here. I will do so in the next patch.

            I do not think this is the problem though as some of the .png files do not have this character in the name...

            I will add some trace code (and remove the ¶ character) if you do not mind testing again CMD.

            http://www.keepingmyhandin.com/

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 4 Dec 2012, 12:06

              Why no just remove the miscreant character OR use an _ ?

              TIG

              1 Reply Last reply Reply Quote 0
              • O Offline
                Oxer
                last edited by 4 Dec 2012, 12:19

                The same like cmd, the folders and image files do exist.

                Captura de pantalla 2012-12-04 a la(s) 13.17.16.png
                ENV.sort.each{|e|p e};p

                Captura de pantalla 2012-12-04 a la(s) 13.13.54.png

                "The result is the end what is important is the process" by Oxer
                [http://www.oxervision.blogspot.com/(http://www.oxervision.blogspot.com/)]

                1 Reply Last reply Reply Quote 0
                • M Offline
                  Myhand
                  last edited by 4 Dec 2012, 12:37

                  @tig said:

                  Why no just remove the miscreant character OR use an _ ?

                  Three reasons (none valid anymore)

                  • I wanted descriptive file names (help with debugging)
                  • I wanted to be clear which chars I replaced (helped with debugging)
                  • I also have an OCD nerve and in theory by just deleting or replacing with a "ordinary" character could clash two similarly names materials that only differed in special characters (and yes it could still happen if each string have the same number of special characters all in the same positions but different characters or if someone actually used the ¶) but I felt the chances were sufficiently small.

                  I will probably go for using object_id as it will be exact(which I did not know existed when I wrote this part if the code initially).

                  http://www.keepingmyhandin.com/

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

                    You could make a ruby hash of each material 'display-name'/'id' [rather than it's Sketchup name which will involve [], <> etc if it has been 'imported' etc; this 'display-name' is used in the dialog, and it is then linked to the material's 'id' in the hash. That 'id' is then used for the temp thumbnail png file-name. They are both already unique.

                    The same applies to the component-thumbnail etc.

                    You can then use the linked name/id to find the material/defn / id, to associate the right png with the material/defn etc...

                    TIG

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

                      @tig said:

                      You could make a ruby hash of each material 'display-name'/'id' [rather than it's Sketchup name which will involve [], <> etc if it has been 'imported' etc; this 'display-name' is used in the dialog, and it is then linked to the material's 'id' in the hash. That 'id' is then used for the temp thumbnail png file-name. They are both already unique.

                      The same applies to the component-thumbnail etc.

                      You can then use the linked name/id to find the material/defn / id, to associate the right png with the material/defn etc...

                      Is there a reason I not just use the the material's object_id.to_s() as key and also as thumbnail file name etc. It seems unnecessary to concatenate with display_name and then hash, when object_id should be unique within one session...?

                      http://www.keepingmyhandin.com/

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        TIG Moderator
                        last edited by 4 Dec 2012, 15:28

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

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          Myhand
                          last edited by 4 Dec 2012, 16:11

                          @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 4 Dec 2012, 22:15

                            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 5 Dec 2012, 05:59

                              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
                              • T Offline
                                thomthom
                                last edited by 5 Dec 2012, 08:26

                                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
                                • T Offline
                                  TIG Moderator
                                  last edited by 5 Dec 2012, 10:21

                                  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
                                  • T Offline
                                    thomthom
                                    last edited by 5 Dec 2012, 15:00

                                    [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
                                    • T Offline
                                      TIG Moderator
                                      last edited by 5 Dec 2012, 15:43

                                      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 6 Dec 2012, 23:59

                                        @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 7 Dec 2012, 02:46

                                          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
                                          • 1
                                          • 2
                                          • 3
                                          • 4
                                          • 5
                                          • 6
                                          • 7
                                          • 8
                                          • 5 / 8
                                          5 / 8
                                          • First post
                                            96/155
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement