Home Technical Talk

select object by material ID

Anyone know of a script which will select all objects in a scene based on their multi sub object material ID? Selecting an object by material doesn't respect material ID's so you just get every object with that multi sub material applied to it.

I would have thought its something people want to do often but having looked into it i cant find a solution and no one at work knows.

Thanks in advance.

Replies

  • Slum
    Options
    Offline / Send Message
    Slum polycounter lvl 18
    The problem here is that objects don't have material ID's, only faces do. You can get around this by grabbing the material ID of a random face on the object and assuming that's the correct material ID. But, this breaks if you have multiple material ID's on an object.
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    Sounds like to do this properly, you'd have to get the total number of different material IDs in use, per object. If that total is 1, then you know the whole object is using just one material, and it's safe to just take the material ID of any face and know that it's applied to the whole object.

    Might be slow to iterate over large, complex scenes, though... unless there's a MaxScript command for getting the number of material IDs per object (which there might well be, I haven't checked). If there isn't, you're going to have to brute-force scan all faces in the object and test for more than one MatID result.
  • frubes
    Options
    Offline / Send Message
    Thanks for the input chaps. The scene is huge (approx 9k objects not including Vray proxies) I found a script which detaches faces based on material ID which has helped to be able to isolate the material ID's into objects. Now i know that each object only has 1 ID it should be simpler.
Sign In or Register to comment.