Monday, April 30, 2012

Material By Element - 0.9

Hello guys,
today I finally found the time to clean out the code and to organize interface:



downlad link:
material_by_element.py

A few words about this script
The goal would be, having an object with some element (like rooftile or bricks):
  1. generate 'N' materials based on the first and varying diffuse color of 'K
  2. splitt the former mesh into more objects
  3. apply randomly the materials to each object
Beside this 'core functionality' I needed some more functions:
  • find a precise 'mbe' list, in order to have more in one scene without contrast
  • select all objects involved in a selected list
  • find out objects without material (in a big scene could be tricky)
  • remove all unused material from scene (I know: just restart blender. But the keyword is: FAST and EASY)
  • completely remove active material from scene and objects with one click
  • completely remove materials of an 'mbe' list from scene and objects, and get back base material
  • any suggestion? :-)
For more explanation I suggest you to read previous posts about "Material By Element".


MORE INFO:
the scripts is able to find materials throug a marker string ('.mbe-') and the basename (all you have before marker) so... DON'T change material's name after, because you could have problems.


Installation: copy python script into your addons folder and check it on into "User Preferences\Addons\Material"
more info at http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Add-Ons


As soon as possible I'll make videotutorial, wikipage and all that "bureocraty" stuff :)


The script is released under GPL 2.0, feel free to reuse/modify/cook/freeze/blend... but please let me know :-) I'm curious.


Pietro

2 comments:

  1. This is a very nice addon!!
    I tried to find a solution for this through other means.
    If you make 5 materials for one object, I tried to do a script that would assign a random of these materials to each subobject, face or optionally to different vertex-groups.
    Is it possible to make completely different materials and let the addon cycle through those instead of only varying the diffuse color?
    Again nice idea and work.

    ReplyDelete
    Replies
    1. Hi Ejnar, thank you!
      It is possible this way, but at the moment it's very tricky: you've got to generate a list from one material, delete list (del MBE bro) and rename the other material you want to be cycled with "basename"+".mbe-"+### and finally select all objects keeping active the one with the first material and playing "Assign".
      I'm working on sub-assignment and cycles compatibility too!

      Delete