Material Utilities for Blender 2.8

Hi guys!

When I started using Blender 2.8 I was really missing the “Material Utils Specials” Add-on. But I couldn’t find a version for 2.8 (or any in development), so I decided to try it myself.

So now it’s time to release the “first” version of my adaption: Material Utilities.
(It’s still label as “Beta”, mostly because I’m the only one who’ve tested it so far. I’ve tried to test as many aspects as possible, and have fixed all the bugs I’ve found. But I can’t guarantee that it’s bug free!)

Most of the same functionality is there (except things related to the “Blender Render”), but there’s maybe 1 or 2 missing.
But there’s also some more functions/operators and most of the functions have some added options!

Everything has (some) documentation in the README.

I hope you like it and find it useful!

17 Likes

Thanks very much, I really am disappointed I never found time to fix this for 2.8, I’ll test it out and let you know how it goes.
@Michael_W take a look here

2 Likes

The good news.Thanks for this good job

1 Like

I was missing this a lot, thank you very much. I’m actually surprised it isn’t in trunk

edit, I just noticed Meta’s reply, that clears up why it isn’t in trunk :smiley:

2 Likes

This is exactly what I was looking for. I posted about the missing Materials Specials menu in 2.8, and I didn’t realize (or forgot) it was an addon in 2.7x. In any case, this menu is really useful.

1 Like

Great. Most missed.

1 Like

Glad you guys like it!

I have now done some updates to the Add-on (current version being 2.1.0).
Here’s some of the news:

  • New operator: Join By Material
  • There is now a Search option in the Assign and Select menus*
  • It now has preferences, so you can set up some default values as you like them.
  • Some small UI/UX updates
    (See the CHANGELOG for more detalis)

(* I was working on a project with 50+ materials and thought that a “search function would be nice”, so now there is one… It just opens the operator panel in a dialog, but still, it’s helpful and might be nicer than scrolling to a long list.)

3 Likes

hi @ChrisH_Swe, there’s now a built in function for “Remove Unused Slots”, this could be added to the pop up menu. Of course you would only need to use the built in operator in the pop up.
There’s a difference in behavior between the remove unused and the clean slots in the addon:
The built in function removes unused slots from active object.
The addon function removes unused slots from all selected objects.

Again I thank you for the update, it’s saved much time, I’ll be looking at adding Materials Utils back to Blender shortly. Materials Utils has been a collaborative effort for some time now as you can see by the list of contributors. You are most welcome to participate here. I have further concepts that may work and are worth discussing. If you were to join https://blender.chat/home #python channel, we can discuss in real time.
I’ve also sent you a pm.
Thanks again.

I use a small script, if anyone find it useful. (It also sets autosmooth and angle of 35 but you can comment those lines out).

ClearMslots.py (1.1 KB)

2 Likes

Hi @Meta-Androcto & @colkai!

Is that function a thing in an official build yet?
I’m using the Stable version (from 30th July, so maybe not truly the “latest”) and can’t find it. And if I try to run bpy.ops.view3d.clean_material_slots() (or bpy.ops.object.material_slot_remove() ) I get an error (“Could not be found”).

I saw that it was added as an commit last Wednesday (31st July), so maybe it will be included in 2.81!?
(I also know some other add-on[s] have added that operator, which might be the bpy.ops.view3d.clean_material_slots operator).

It might be a good idea to use that operator, but I’m not inclined to do that until it at least is in stable (or in a version that ships with a Blender version which has that…).

I did however update the Clean Material Slots operator, so it now has an operator panel (like the other operators under Clean Slots).

And @colkai inspired by your script I added an operator to set the Auto Smooth Angle for multiple objects (It’s currently in the Dev-branch)! :slight_smile:

1 Like

The built in function has been there since 2.79, but it only works on a single active object. I just use a script to run through all objects if I’m working on an object I end up splitting into parts. If we could do the “alt-click” thing like you can for smoothing etc the script would be redundant, so hopefully at some point, they will provide that ability. When I am working normally, I’ll use “clean material slots” as I go along. :slight_smile:
To be honest, I hadn’t run it in 2.80 so wasn’t ware of the api change. There’s beeen a few, so just be a case of figuring out what it is.
EDIT: Hmm, no, not seeing the ability to use it per object either in 2.80, that’s frustrating.
Edit Edit: :crazy_face:
Ahh…

I’ve noticed in the dev version:line 210 in init
del bpy.types.Scene.material_utilities is problematic when reloading the addon.
It’s looking good so far. The first version is in release nightly builds, maybe we could use the dev version soon?

I checked in 2.79, and it’s actually not a part of the official API. But the function your script is calling is actually a part of Material Utils Specials Add-on (Which this add-on is based on/an continuation of).
(Disable the add-on and you can’t call that function…) :smiley:

1 Like

I didn’t try to disable the add-on after I added the preferences, so didn’t catch that (My bad!)!
But it’s fixed now*, and the Dev branch has been merged into Master on GitHub.

I’m using the add-on daily and I’m tempted to remove the Beta-label. It’s maybe not “widely” tested, so perhaps too soon. But in my use I haven’t come across any bugs (except the one you found…).

(*Ended up not using that variable anyway, just forget to remove it from unregister)

This is great! I still wish someone re-created almost the Material Editor from 3DS Max, for Blender. But this is very nice. :smiley: Awesome work!

The clean Slots is very nice. I had that issue with geo from Max, where my MultiMaterial came in and had like 20 materials on an object, but really only needed the 1. Also blender seems to import ALL materials again/unique, if all geo/materials aren’t merged/imported at once. Meaning, even if its using the same material in max, blender makes it all unique, which can be annoying for sure. But this tool can help fix that :slight_smile:

Is there a way to purge all un-used / orphan materials in the entire scene?

only one thing I can tell you: thank you
:star_struck:

1 Like

Thank you a lot ! it was really needed addon <3

This add-on could be very useful for me. When populating scenes out of the Simple Asset Manager, the (same) materials keep piling up, so I would like to do some kind of a batch clean up.

However I can’t get the add-on working. I downloaded the zip, installed in Blender (command line in Blender says it has installed). But it doesn’t show up anywhere in Blender/Preferences/Add-ons.

Any ideas?

Hi,

thanks for an awesome add-on! However, I’m having trouble with the “Remove all material slots”-command. If I have more than two slots in the mesh, Blender will crash. Any help would be appreciated.

1 Like

I’ll echo what others have said, thank you for this Add-On, it’s awesome!

I do have a bug to report though. I found if I send a mesh from 3DS Max as FBX, with Multi Materials/Multi Material Slots, all is good. But if I try to then “Remove All Material Slots” with your tool, I can get an instant Blender Crash, with no warnings or anything at all.

Here’s a file to test with, if you would be able to. Thank you again! :slight_smile:

multi_mat_clean_crash.blend (881.1 KB)

Edit:

So I was looking at the code, and it looks like you/he is using a built in blender function to clear the materials I think… which crashes the program. So I think I/we may have to actually report this as a real bug , and is not an issue with this Add-on Specifically… ?

This can crash blender.

    obj = bpy.context.active_object

    # Clear out the material slots
    obj.data.materials.clear()

Edit: I tested in latest Blender 2.82 Build and it doesn’t seem to crash anymore… !

Looks like was fixed back in August. I will test another thing they mentioned to see if can still get around the issue in 2.8 Release.

https://developer.blender.org/rBc70f975d5c3b961e0c77eba3a35c8a892f39214d