Announcement

Collapse
No announcement yet.

Select all wih no material

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select all wih no material

    Hi There,

    anybody know of a script that can select all objects in scene with no materials applied to them?

    regards,
    Wim

  • #2
    Just happen to have a small script that does just that. We use it when working with Revit files as a quick way to grab anything that doesn't have a material already assigned.

    Installation: Maxscript / Run script. Find it in the category "CG_Tools" in Customize / Customize User Interface.

    Usage: select objects and it'll only select those within your original selction that don't have a material or run it without anything selected and it'll look for objects in the entire scene (hidden/frozen/etc) that don't have a material.
    Attached Files
    Christopher Grant
    Director of Visualization, HMC Architects
    Portfolio, ChristopherGrant.com

    Comment


    • #3
      Excellent! thank you!

      Comment


      • #4
        easy!

        [Script]

        clearSelection()
        for o in objects where isProperty o #material do (
        if o.material == undefined then
        selectmore o
        )

        [/Script]
        Colin Senner

        Comment


        • #5
          The above line by line means:

          clearSelection()
          - Clears the objects you currently have selected in the scene

          for o in objects where isProperty o #material do (
          - the word "objects" is a reserved keyword referring to every (selectable) object (node) in the scene (cameras, lights, etc), where "o" refers to each of those objects
          - isProperty o #material checks that o.material (o being one of the objects in the scene) exists, so obviously cameras and lights will not meet this condition so they won't be selected, this sets up the call to o.material (which would error out if you had a camera selected and did $.material, because camera's don't have a material property)

          if o.material == undefined then
          - Checks to see if the material is undefined (referred to as NULL in other languages)

          selectmore o
          - If you use "select o" then the script will complete and the last object that had no material applied would be selected and not all of the previous ones

          )
          - Terminates the for loop

          Hope this helps
          Colin Senner

          Comment


          • #6
            instead of the "objects" set you can use "geometry",
            here is my version that i'm using all the time:

            Code:
            clearSelection()
            for i in geometry where i.material == undefined do selectmore i
            Marc Lorenz
            ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
            www.marclorenz.com
            www.facebook.com/marclorenzvisualization

            Comment


            • #7
              Problem with the above script is it won't get renderable splines without a material, which is why I wouldn't use "geometry". Geometry only uses objects defined under the geometry subclass, which renderable splines wouldn't be even though they can be renderable geometry.

              And I'll amend mine to the following so it won't select cameras and lights (which I just checked have a #material property)

              Code:
              clearSelection()
              for o in objects where (isKindOf o shape and o.render_renderable) or (isKindof o geometryClass) and o.material == undefined do selectmore o
              Last edited by MoonDoggie; 21-09-2010, 12:58 PM.
              Colin Senner

              Comment


              • #8
                Ah, OK...didn't think about editable splines, since I never use them.
                Probably both versions have their place.
                Marc Lorenz
                ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
                www.marclorenz.com
                www.facebook.com/marclorenzvisualization

                Comment


                • #9
                  Thank you!
                  and thanks for explaining the script.

                  regards,
                  Wim

                  Comment


                  • #10
                    That's exactly why I hate MAXScripting, everything is so damn complicated. The way max handles BitmapTextures is absolutely ridiculous and makes no sense why it can't find them in displace modifiers, environment tabs, etc. You just have to hack your way around it like crazy. Oi. I love programming, but seriously max, re-write your stuff so it makes some sense, stop adding features to maxscript when the whole system was built in max 3.0...

                    -Colin
                    Colin Senner

                    Comment

                    Working...
                    X