Home Technical Talk

Maxscript : getting material from bitmap ?

greentooth
Offline / Send Message
Noors greentooth
Ola,

Let's say i have a multimaterial, with standard submaterials in it, with a diffuse texture in each of the submaterial.

In the material editor, my current slot is on a diffuse bitmap node.
I want to access the parent standard material from here. Not the root multimaterial.
(Purpose is to rename the standard material as the diffuse name).

This is what i came with :
damat = for ref in refs.dependents (medit.GetCurMtl())  where (classOf ref == standardMaterial) collect ref

It works but i feel like it's a bit dirty to cycle into the node dependencies. Couldn't think of a better way to get a bitmap material parent. Ideas ?
Thanks!

Replies

  • monster
    Options
    Offline / Send Message
    monster polycounter
    I think your method is sound. The only problem that may develop is that if you have your texture plugged into several materials you'll need to figure out which one to rename.

    Personally I would select the multimaterial node and recurse the materials.
  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    Yep indeed, i have an issue with instanciated bitmaps. I don't think i can do much.

    It's an issue only with multi mat, else medit.GetTopMtlSlot get me the material. So i'll just put a warning to select bitmap direct parent when root mat is a multi.

    Yeah i recurse the submaterials and rename them all at multi level. But when on a submaterial or its bitmap, i wanted to rename just that material. I guess it will only be at submaterial level then.

    Thanks !
  • monster
    Options
    Offline / Send Message
    monster polycounter
    Oh yeah, I had a custom attribute that was only supposed to be applied to standard materials and not multimaterials or bitmaps. If they didn't have the right thing selected, I just put up a messageBox saying, "Custom Attribute may only be applied to Standard Materials." No one ever got confused on how to use the tool.
  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    Haha, just wanted to say i asked the exact same question on cgtalk 5 years ago and got the answer. How fucking dumb am i ?
    I just have to cycle into submaterials till i find one with the right diffuse. I just can't think backwards.
    One day, i was looking for doing a certain thing in Maya. Found a post of a guy detailing nicely all the process, then realized that guy was me posting, like 4 years before. Cool story uh.
  • cptSwing
    Options
    Offline / Send Message
    cptSwing polycounter lvl 11
    Noors wrote: »
    One day, i was looking for doing a certain thing in Maya. Found a post of a guy detailing nicely all the process, then realized that guy was me posting, like 4 years before.


    haha, yeah cool story bra ;)
Sign In or Register to comment.