[Bf-extensions-cvs] [8bcab7a3] master: materials_utils: return to release: T67990 T63750 01d80b8f602f
meta-androcto
noreply at git.blender.org
Sun Aug 11 07:52:22 CEST 2019
Commit: 8bcab7a3c5f90f9a49d5ca3dcc1a70fc960f0040
Author: meta-androcto
Date: Sun Aug 11 15:52:03 2019 +1000
Branches: master
https://developer.blender.org/rBAC8bcab7a3c5f90f9a49d5ca3dcc1a70fc960f0040
materials_utils: return to release: T67990 T63750 01d80b8f602f
===================================================================
D materials_utils/__init__.py
D materials_utils/enum_values.py
D materials_utils/functions.py
D materials_utils/menus.py
D materials_utils/operators.py
===================================================================
diff --git a/materials_utils/__init__.py b/materials_utils/__init__.py
deleted file mode 100644
index 40f976d7..00000000
--- a/materials_utils/__init__.py
+++ /dev/null
@@ -1,179 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-# Based on 2010 version by MichaelW
-# (c) 2016 meta-androcto, parts based on work by Saidenka, lijenstina
-# Materials Utils: by MichaleW, meta-androcto, lijenstina,
-# (some code thanks to: CoDEmanX, SynaGl0w, ideasman42)
-# Link to base names: Sybren, Texture renamer: Yadoob
-# Ported from 2.6/2.7 to 2.8x by Christopher Hindefjord (chrishinde) 2019
-
-bl_info = {
- "name": "Material Utils",
- "author": "MichaleW, ChrisHinde",
- "version": (1, 0, 6),
- "blender": (2, 80, 0),
- "location": "View3D > Shift + Q key",
- "description": "Menu of material tools (assign, select..) in the 3D View",
- "warning": "",
- "wiki_url": "https://github.com/ChrisHinde/MaterialUtilities",
- "category": "Material"
-}
-
-"""
-This script has several functions and operators, grouped for convenience:
-
-* assign material:
- offers the user a list of ALL the materials in the blend file and an
- additional "new" entry the chosen material will be assigned to all the
- selected objects in object mode.
-
- in edit mode the selected polygons get the selected material applied.
-
- if the user chose "new" the new material can be renamed using the
- "last operator" section of the toolbox.
-
-
-* select by material
- in object mode this offers the user a menu of all materials in the blend
- file any objects using the selected material will become selected, any
- objects without the material will be removed from selection.
-
- in edit mode: the menu offers only the materials attached to the current
- object. It will select the polygons that use the material and deselect those
- that do not.
-
-* clean material slots
- for all selected objects any empty material slots or material slots with
- materials that are not used by the mesh polygons or splines will be removed.
-
-* remove material slots
- removes all material slots of the active (or selected) object(s).
-
-* replace materials
- lets your replace one material by another. Optionally for all objects in
- the blend, otherwise for selected editable objects only. An additional
- option allows you to update object selection, to indicate which objects
- were affected and which not.
-
-* set fake user
- enable/disable fake user for materials. You can chose for which materials
- it shall be set, materials of active / selected / objects in current scene
- or used / unused / all materials.
-
-"""
-
-
-import bpy
-
-from .enum_values import *
-from .functions import *
-from .operators import *
-from .menus import *
-
-# All classes used by Material Utilities, that need to be registred
-classes = (
- VIEW3D_OT_materialutilities_assign_material_object,
- VIEW3D_OT_materialutilities_assign_material_edit,
- VIEW3D_OT_materialutilities_select_by_material_name,
- VIEW3D_OT_materialutilities_copy_material_to_others,
-
- VIEW3D_OT_materialutilities_clean_material_slots,
- VIEW3D_OT_materialutilities_remove_material_slot,
- VIEW3D_OT_materialutilities_remove_all_material_slots,
-
- VIEW3D_OT_materialutilities_replace_material,
- VIEW3D_OT_materialutilities_fake_user_set,
- VIEW3D_OT_materialutilities_change_material_link,
-
- MATERIAL_OT_materialutilities_merge_base_names,
-
- MATERIAL_OT_materialutilities_material_slot_move,
-
- VIEW3D_MT_materialutilities_assign_material,
- VIEW3D_MT_materialutilities_select_by_material,
-
- VIEW3D_MT_materialutilities_clean_slots,
- VIEW3D_MT_materialutilities_specials,
-
- VIEW3D_MT_materialutilities_main,
-)
-
-
-# This allows you to right click on a button and link to the manual
-def materialutilities_manual_map():
- print("ManMap")
- url_manual_prefix = "https://github.com/ChrisHinde/MaterialUtilities"
- url_manual_map = []
- #url_manual_mapping = ()
- #("bpy.ops.view3d.materialutilities_*", ""),
- #("bpy.ops.view3d.materialutilities_assign_material_edit", ""),
- #("bpy.ops.view3d.materialutilities_select_by_material_name", ""),)
-
- for cls in classes:
- if issubclass(cls, bpy.types.Operator):
- url_manual_map.append(("bpy.ops." + cls.bl_idname, ""))
-
- url_manual_mapping = tuple(url_manual_map)
- #print(url_manual_mapping)
- return url_manual_prefix, url_manual_mapping
-
-mu_classes_register, mu_classes_unregister = bpy.utils.register_classes_factory(classes)
-
-
-def register():
- """Register the classes of Material Utilities together with the default shortcut (Shift+Q)"""
- mu_classes_register()
-
- bpy.types.VIEW3D_MT_object_context_menu.append(materialutilities_specials_menu)
-
- bpy.types.MATERIAL_MT_context_menu.prepend(materialutilities_menu_move)
- bpy.types.MATERIAL_MT_context_menu.append(materialutilities_menu_functions)
-
- kc = bpy.context.window_manager.keyconfigs.addon
- if kc:
- km = kc.keymaps.new(name = "3D View", space_type = "VIEW_3D")
- kmi = km.keymap_items.new('wm.call_menu', 'Q', 'PRESS', ctrl = False, shift = True)
- kmi.properties.name = VIEW3D_MT_materialutilities_main.bl_idname
-
- bpy.utils.register_manual_map(materialutilities_manual_map)
-
-
-def unregister():
- """Unregister the classes of Material Utilities together with the default shortcut for the menu"""
- mu_classes_unregister()
-
- bpy.utils.unregister_manual_map(materialutilities_manual_map)
-
- bpy.types.VIEW3D_MT_object_context_menu.remove(materialutilities_specials_menu)
-
- bpy.types.MATERIAL_MT_context_menu.remove(materialutilities_menu_move)
- bpy.types.MATERIAL_MT_context_menu.remove(materialutilities_menu_functions)
-
- kc = bpy.context.window_manager.keyconfigs.addon
- if kc:
- km = kc.keymaps["3D View"]
- for kmi in km.keymap_items:
- if kmi.idname == 'wm.call_menu':
- if kmi.properties.name == VIEW3D_MT_materialutilities_main.bl_idname:
- km.keymap_items.remove(kmi)
- break
-
-
-if __name__ == "__main__":
- register()
diff --git a/materials_utils/enum_values.py b/materials_utils/enum_values.py
deleted file mode 100644
index f7f8f65b..00000000
--- a/materials_utils/enum_values.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import bpy
-
-
-mu_override_type_enums = [
- ('OVERRIDE_ALL', "Override all assigned slots",
- "Remove any current material slots, and assign the current material"),
- ('OVERRIDE_SLOTS', 'Assign material to each slot',
- 'Keep the material slots, but assign the selected material in each slot'),
- ('APPEND_MATERIAL', 'Append Material',
- 'Add the material in a new slot, and assign it to the whole object')
-]
-
-mu_fake_user_set_enums = (('ON', "On", "Enable fake user"),
- ('OFF', "Off", "Disable fake user"),
- ('TOGGLE', "Toggle", "Toggle fake user"))
-mu_fake_user_materials_enums = (('ACTIVE', "Active object", "Materials of active object only"),
- ('SELECTED', "Selected objects", "Materials of selected objects"),
- ('SCENE', "Scene objects", "Materials of objects in current scene"),
- ('USED', "Used", "All materials used by objects"),
- ('UNUSED', "Unused", "Currently unused materials"),
- ('ALL', "All", "All materials in this blend file"))
-
-mu_link_to_enums = (('DATA', "Data", "Link the materials to the data"),
- ('OBJECT', "Object", "Link the materials to the object"),
- ('TOGGLE', "Toggle", "Toggle what the materials are currently linked to"))
-mu_link_affect_enums = (('ACTIVE', "Active object", "Materials of active object only"),
- ('SELECTED', "Selected objects", "Materials of selected objects"),
- ('SCENE', "Scene objects", "Materials of objects in current scene"),
- ('ALL', "All", "All materials in this blend file"))
-
-mu_material_slot_move_enums = (('TOP', "Top", "Move slot to the top"),
- ('BOTTOM', "Bottom", "Move slot to the bottom"))
diff --git a/materials_utils/functions.py b/materials_utils/functions.py
deleted file mode 100644
index 6c8c72bd..00000000
--- a/materials_utils/functions.py
+++ /dev/null
@@ -1,604 +0,0 @@
-import bpy
-
-# -----------------------------------------------------------------------------
-# utility functions
-
-def mu_assign_material_slots(object, material_list):
- """Given an object and a list of material names removes all material slots from the object
- adds new ones for each material in the material list, adds the materials to the slots as well."""
-
- scene = bpy.context.scene
- active_object = bpy.context.active_object
- bpy.context.view_layer.objects.active = object
-
- for s in object.material_slots:
- bpy.ops.object.material_slot_remove()
-
- # re-add them and assign material
- i = 0
- for mat in material_list:
- material = bpy.data.materials[mat]
- object.data.materials.append(material)
- i += 1
-
- # restore active object:
- bpy.context.view_layer.objects.active = active_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list