Announcement

Collapse
No announcement yet.

Select objects by similar material - possible in Maxscript?

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

  • Select objects by similar material - possible in Maxscript?

    Essentially, I would like to group objects by 'similar' material.

    For example, I have a bunch of chrome objects, but for whatever reason they all have different copies of chrome materials applied to them.
    These are identical bar minor variations in glossiness or diffuse colour.

    Is it possible to use Maxscript to select groups of objects that share certain material similarities?

    Or where the materials share certain similarities within some chosen thresholds?

  • #2
    Haven't tested this and you'll need to play around and try settings yourself to see if you can get this to work, this may get too many matches. Comment out a line by putting -- before a line.

    Code:
    diffuseColorTollerance = 10
    reflectionColorTollerance = 10
    IORTollerance = 0.2
    
    myObjs = #()
    
    if selection.count == 1 and selection[1].material != undefined and classof selection[1].material == VrayMtl then
    (
    testObj = selection[1]
    testmat = selection[1].material
    
    
    for o in objects where o.material != undefined and classof o.material == VrayMtl do
    (
        isSimilar = false
        mat = o.material
        if abs(testmat.diffuse.r - mat.diffuse.r) < diffuseColorTollerance do isSimilar = true
        if abs(testmat.reflection.r - mat.diffuse.r) < reflectionColorTollerance do isSimilar = true
        if abs(testmat.reflection_ior - mat.reflection_ior) < IORTollerance do isSimilar = true
    
        if isSimilar do append myObjs o
    )
    select myObjs
    )
    else
        MessageBox "Please Select One Object"
    Maxscript made easy....
    davewortley.wordpress.com
    Follow me here:
    facebook.com/MaxMadeEasy

    If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

    Comment


    • #3
      bam. good idea, good execution. ty!
      Lele
      Trouble Stirrer in RnD @ Chaos
      ----------------------
      emanuele.lecchi@chaos.com

      Disclaimer:
      The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

      Comment


      • #4
        Cool thanks!
        Dave to the rescue once again.
        Think I understand what you have done here, and in theory should be easy to add further parameters, glossiness etc.

        I wonder, how on earth does one amend this so it can work with maps? Is it even possible.

        Comment


        • #5
          showProperties (VrayMtl())

          Will give you all the property types....
          Maxscript made easy....
          davewortley.wordpress.com
          Follow me here:
          facebook.com/MaxMadeEasy

          If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

          Comment


          • #6
            Sure, thats everything I need to add glossiness etc.
            But for maps, there's no way to get the resulting glossiness value from the map is there?

            So if I have a metal with a glossiness of 0.8 and another metal with a glossiness map that hits 0.8 as its lowest value, is there a way to determine this via script?

            Comment


            • #7
              You'd have to try and sample the bitmaps in the slot which'd be kinda sloooooowww

              Comment

              Working...
              X