Announcement

Collapse
No announcement yet.

Replace Material Python Script??

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

    Replace Material Python Script??

    Is there a tutorial somewhere that can walk us through (or let us download) a python script to replace materials? In this video, posted by Unreal Engine, the instructor runs what seems to be a very short and simple script to change materials. The video is horrible quality so it's impossible to read the code, and zero instructions are given as to how one might find that script or build it yourself. The python script is at the 10:00 mark.

    https://www.youtube.com/watch?v=iuqT...44316015108683

    This is an Unreal Studio/Datasmith based video. What's confusing is that I'm not sure how the script would work with Datasmith; given that material pathways for imported objects are very specific to the folder structure. If your workflow means multiple Datasmith imports to build a scene, how does the script find those materials?


    There's also this page from Unreal that features some sort of method to replace materials, but there's zero instructions for the beginner as to how any of it works.
    https://unrealstudiohelp.epicgames.c...l-Studio-Users

    Tnx much.


    #2
    Good morning,

    Here is another video using python to replace these materials, the script is at 0:57
    https://www.youtube.com/watch?v=sj53pLUdLyk

    Is it what you are looking for?
    Have An Awesome And Productive Day
    Alex, Youtube Tutorials

    Comment


      #3
      Yes, nice one! I've gone ahead and tried to copy the script but can't get it working. Probably my syntax!?

      import unreal

      def replace_material(original, replacement):
      original_asset =
      unreal.EditorAssetLibrary.load_asset(original)
      replacement_asset =
      unreal.EditorAssetLibrary.load_asset(replacement)
      unreal.EditorAssetLibrary.consolidate_assets(replacement_asset, [original_asset])

      #replace_material(original_name, replacement_name)
      replace_material("/Materials/M_01", "/Materials/B_001")

      Comment


        #4
        I'm moving this topic over to the Python section. If I get an answer there I will post that here as well. It's my feeling that swapping out materials for Datasmith users will be an important thing to figure out and incorporate into the workflow!

        https://forums.unrealengine.com/deve...-python-script

        EDIT: With the excellent help of AlexQuevillon, this has been figured out. Just click on that link above to visit the Python forum thread. There's some specific steps after the material swap is made. Tnx again, Alex.
        Last edited by landrvr1; 12-16-2018, 09:22 PM.

        Comment

        Working...
        X