sketchucation logo sketchucation
    • Login
    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!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Windowizer 4 - alphabetical order of materials?

    Scheduled Pinned Locked Moved Plugins
    8 Posts 2 Posters 1.8k Views 2 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.
    • john2J Offline
      john2
      last edited by

      i'm using windowizer 4 . is there any way to arrange the materials listed in the glass materials in alphabetic order when the drop down menu comes?

      Sketchup Make 2017 (64-bit), Vray 4.0 , Windows 10 – 64 bit, corei7-8750H, 16GB RAM, Nvidia GeForce GTX 1050Ti 4GB

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

        The Windowizer4.rb uses
        matlist = getMaterials().split("|")
        to assemble an collection of the available materials, as an array.
        The getMaterials.rb returns a string of all available material-names, separated by '|'.
        It IS sorted... matNames.sort.join('|') - I don't see the issue ?
        The same sorted list of materials is used for frames and glass ??

        TIG

        1 Reply Last reply Reply Quote 0
        • john2J Offline
          john2
          last edited by

          I don't know ruby..hence i don't know what you're saying πŸ˜•

          here are two screnshots

          http://i.imgur.com/kqYfC.jpg

          http://i.imgur.com/DEY7G.jpg

          Sketchup Make 2017 (64-bit), Vray 4.0 , Windows 10 – 64 bit, corei7-8750H, 16GB RAM, Nvidia GeForce GTX 1050Ti 4GB

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

            Open the Ruby Console and type this word + <enter>
            getMaterials
            It needs to be exactly as it's written [or Copy/Paste]
            It should return a list of Materials in the model sorted by their names [separated by '|'] ?
            It does that for me... and that's the code used inside Windowizer4 too.
            Do you have the current getMaterials.rb [comes from Smustard.com with Windowizer4 ?] ?
            If it doesn't work try this - Copy/Paste this code it should again be sorted...
            matNames=[];Sketchup.active_model.materials.each{|e|matNames<<e.name};matNames.sort
            πŸ˜•

            TIG

            1 Reply Last reply Reply Quote 0
            • john2J Offline
              john2
              last edited by

              @tig said:

              Open the Ruby Console and type this word + <enter>
              getMaterials
              It needs to be exactly as it's written [or Copy/Paste]
              It should return a list of Materials in the model sorted by their names [separated by '|'] ?
              It does that for me... and that's the code used inside Windowizer4 too.
              Do you have the current getMaterials.rb [comes from Smustard.com with Windowizer4 ?] ?
              If it doesn't work try this - Copy/Paste this code it should again be sorted...
              matNames=[];Sketchup.active_model.materials.each{|e|matNames<<e.name};matNames.sort
              πŸ˜•

              i have one getmaterials and it has this text

              def getMaterials
              model=Sketchup.active_model
              mats=model.materials
              matNames=[]
              []
              mats.each {|e| matNames.push(e.name)}
              matList=matNames.join('|')
              return matList
              end

              no version

              your code [rubymatNames=[];Sketchup.a.......] works but do i need to type this everytime?? cant my plugin be edited by adding a line or two?

              Sketchup Make 2017 (64-bit), Vray 4.0 , Windows 10 – 64 bit, corei7-8750H, 16GB RAM, Nvidia GeForce GTX 1050Ti 4GB

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

                Try this...
                Make a copy of windowizer4.rb - outside of the Plugins folder so it doesn't auto-load and confuse the issue! IF you screw up you can use it to replace the one you about to attempt a recode on !!
                Edit the windowizer4.rb file that's in the Plugins folder using Notepad.exe [or an equivalent plain-text editor - NOT a wordprocessor as that will add formating and break the script !]
                Find the second line containing the text ' getMaterials' [it's around line#299] that says...
                matlist = getMaterials().split("|")
                add a '#' to the start of that text thus...
                #matlist = getMaterials().split("|")
                This stops the line of code being read at all.
                Now add this new line of code immediately below it...
                matlist=[];@model.materials.each{|e|matlist<<e.name};matlist.sort!
                This will make the list in the same way that you did manually in the test I gave you [hopefully successfully again], without the need for ' getMaterials' at all.
                The 'wording' is slightly tweaked to suit the script's coding.
                Save/close and restart Sketchup to auto-reload the script.
                See if the materials lists are now properly ordered...
                πŸ€“

                TIG

                1 Reply Last reply Reply Quote 0
                • john2J Offline
                  john2
                  last edited by

                  I did the coding sir as you said, im getting the following results.

                  im getting results like all the <> materials first, after that capital words sorted alphabetically,

                  then the [] type ones
                  then with small letters

                  http://i.imgur.com/4fH7J.jpg

                  will that be the order ? i mean SU is giving importance on brackets rather than letters

                  Sketchup Make 2017 (64-bit), Vray 4.0 , Windows 10 – 64 bit, corei7-8750H, 16GB RAM, Nvidia GeForce GTX 1050Ti 4GB

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

                    This isn't Sketchup's doing. 😲
                    The 'sort' algorithm in Ruby does a straightforward alphanumeric sort of the 'words'.
                    It depends on ASCII code numbers etc...
                    So punctuation (! # etc), then numbers , then some punctuation (<> etc), then uppercase letters, then some other punctuation ([] etc) and then lowercase letters etc.
                    Paste this in the Ruby Console to see what I mean:
                    ["zebra","Zebra2","456","123","ABC","[xyz]","[abc]","abc","<abc>","#1"].sort
                    The 'bracketry' around the material names is to do with how they have been created/imported etc - read the Help section on this...
                    You could use the 'display_name' [what's show in the Materials Browser] in the sorted list and then have a 'look up table' that uses the materials' 'display_name' against the actual Sketchup 'name'... BUT that some extra coding that RickW needs to do to his script.
                    Why not PM Rick and explain the issues...
                    Windowizer4 is a 'commercial script' - therefore posting too much of its code is 'not on' - I even worried about that one line tweak a gave you !

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement