Announcement

Collapse
No announcement yet.

"Put Material to Scene" and "multi/sub-object" materials problem

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

  • "Put Material to Scene" and "multi/sub-object" materials problem

    I've got an new scene that's a replacement for an old one (both imported from sketchup). Of course I had all of the materials tweaked in the old scene that I'd like to get imported into the new one. My first thought was to just load the old scene into the new one and do a "Put material to Scene" for each of the materials and I could replace the materials that way. The problem is that a lot of the materials are Multi//Sub-Object and put to scene doesn't want to work with that setup. The new scene has all of the same individual materials but their order in some of the multi/sub-object mats are different. So I can't just apply old multi to the new one. Basically I have about a 20 different materials that get put into about 40 different Multi/Sub-Object mats that need to be updated.

    What I want to happen is any new material with the same name as the old one to be updated with an instance of the old one. Am I missing something or is there a script that might help? Any help is appreciated.
    www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

  • #2
    A harsh way to do this, rename the old materials with a "old_" prefix, you can do it manually or use a script to add prefix to all scene materials:
    Code:
     for mtl in scenematerials do mtl.name="old_"+mtl.name
    After merge them into the scene, where you got the new materials which you want to replace, run this script in the listener:
    Code:
     for mtl in scenematerials where matchpattern mtl.name pattern:"old_*" do for newMtl in scenematerials where mtl != newMtl and mtl.name == "old_"+newMtl.name do replaceInstances newMtl mtl
    Basically the script will replace the material named "Concrete" with an instance of "old_Concrete"

    Comment


    • #3
      Worked brilliantly! Thank you so much. FYI: I changed one thing so it would not rename the multimaterials with "old_"...

      Code:
      for mtl in scenematerials where not matchpattern mtl.name pattern:"multi_*" do mtl.name="old_"+mtl.name
      Again, thank you.
      www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

      Comment


      • #4
        Glad it helped,

        your modification will not rename the materials (any type of material) which starts with the name "multi_", the statement considers only the name of it, not the type.
        If you want to consider the type of the material, you can check the classof material itself.

        Code:
        for mtl in scenematerials where classof mtl != Multimaterial do mtl.name="old_"+mtl.name
        that will skip any multimaterial, if you want to rename only multimaterials replace '!=' with '==',

        Comment


        • #5
          Yeah, in this instance all of the multi materials were prefixed with "Multi" so it worked fine but your's is clearly a better solution. thanks!
          www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

          Comment


          • #6
            to me the best way to work with SU and MAX is having individual materials and exporting the model by material.
            show me the money!!

            Comment


            • #7
              Originally posted by flino2004 View Post
              to me the best way to work with SU and MAX is having individual materials and exporting the model by material.
              Good advice. Thanks.
              www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

              Comment

              Working...
              X