[Bf-extensions-cvs] [7eb6d7c0] master: move materials library to release: T51230
meta-androcto
noreply at git.blender.org
Mon Apr 24 02:35:14 CEST 2017
Commit: 7eb6d7c0f3aab57963d1d2f2c2bf8d928aa7cf83
Author: meta-androcto
Date: Mon Apr 24 10:34:43 2017 +1000
Branches: master
https://developer.blender.org/rBAC7eb6d7c0f3aab57963d1d2f2c2bf8d928aa7cf83
move materials library to release: T51230
===================================================================
D materials_library_vx/Cycles_templates.blend
D materials_library_vx/__init__.py
D materials_library_vx/blender_internal.blend
D materials_library_vx/cycles_materials.blend
D materials_library_vx/materials.blend
===================================================================
diff --git a/materials_library_vx/Cycles_templates.blend b/materials_library_vx/Cycles_templates.blend
deleted file mode 100644
index ce97446a..00000000
Binary files a/materials_library_vx/Cycles_templates.blend and /dev/null differ
diff --git a/materials_library_vx/__init__.py b/materials_library_vx/__init__.py
deleted file mode 100644
index 39bb55d2..00000000
--- a/materials_library_vx/__init__.py
+++ /dev/null
@@ -1,1203 +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 #####
-# contributed to by meta-androcto
-
-bl_info = {
- "name": "Material Library VX",
- "author": "Mackraken",
- "version": (1, 0, 1),
- "blender": (2, 77, 0),
- "location": "Properties > Material",
- "description": "Material Library VX",
- "warning": "",
- "wiki_url": "https://sites.google.com/site/aleonserra/home/scripts/matlib-vx-5-6",
- "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
- "category": "Material"}
-
-# TODO: translate comments, cleanup imports, remove dead code, fix xml set fiter crash
-
-import bpy
-import json
-import zipfile
-import urllib.request
-import os
-import sys
-import re
-import csv
-import codecs
-import collections
-import subprocess
-import webbrowser
-from bpy.types import (
- Operator,
- Menu,
- Panel,
- PropertyGroup,
- AddonPreferences,
- )
-from bpy.props import (
- BoolProperty,
- CollectionProperty,
- EnumProperty,
- IntProperty,
- StringProperty,
- PointerProperty,
- )
-
-
-dev = False
-matlib_path = os.path.dirname(__file__)
-
-if dev:
- matlib_path = r"D:\Blender Foundation\Blender\2.72\scripts\addons\matlib"
-
-
-# debug print variables
-def dd(*args, dodir=False):
- if dev:
- if dodir:
- print(dir(*args))
- print(*args)
-
-
-# add-on settings
-def addon_settings():
- # separate function just for more convience
- addon = bpy.context.user_preferences.addons[__name__]
- compact = addon.preferences.use_brushes_menu_type
-
- return compact
-
-
-# Regular Functions
-def winpath(path):
- return path.replace("\\", "\\\\")
-
-
-def update_search_index(self, context):
- search = self.search
- for i, it in enumerate(self.materials):
- if it.name == search:
- self.mat_index = i
- break
-
-
-def check_path(path):
- # isabs sometimes returns true on relpaths
- if path and os.path.exists(path) and os.path.isfile(path) and os.path.isabs(path):
- try:
- if bpy.data.filepath and bpy.path.relpath(bpy.data.filepath) == bpy.path.relpath(path):
- return False
- except:
- pass
- # paths are on different drives. No problem then
- return True
- return False
-
-
-def update_lib_index(self, context):
- self.load_library()
-
-
-def update_cat_index(self, context):
- dd("cat index:", self.current_category, self.filters)
-
- if self.filters:
- self.filters = True
-
-
-def update_filter(self, context):
-
- dd("filter:", self.filters, self.cat_index, self.current_category)
- """
- index = self.cat_index
-
- if self.filters:
- cat = self.current_category
- else:
- cat = ""
-
- self.current_library.filters = cat
- """
- self.update_list()
-
-
-def check_index(collection, index):
- count = len(collection)
- return count > 0 and index < count and index >= 0
-
-
-def send_command(cmd, output="sendmat.py"):
- bin = winpath(bpy.app.binary_path)
- scriptpath = winpath(os.path.join(matlib_path, output))
-
- with open(scriptpath, "w") as f:
- f.write(cmd)
-
- if output == "createlib.py":
- code = subprocess.call([bin, "-b", "-P", scriptpath])
- else:
- libpath = winpath(bpy.context.scene.matlib.current_library.path)
- code = subprocess.call([bin, "-b", libpath, "-P", scriptpath])
-
- # code returns 0 if ok, 1 if not
- return abs(code - 1)
-
-
-def list_materials(path, sort=False):
- list = []
- with bpy.data.libraries.load(path) as (data_from, data_to):
- for mat in data_from.materials:
- list.append(mat)
-
- if sort:
- list = sorted(list)
- return list
-
-
-# category properties (none atm)
-class EmptyGroup(PropertyGroup):
- pass
-
-
-bpy.utils.register_class(EmptyGroup)
-
-
-class matlibMaterials(PropertyGroup):
- category = StringProperty()
-
-
-bpy.utils.register_class(matlibMaterials)
-
-
-# bpy.types.Scene.matlib_categories = CollectionProperty(type=EmptyGroup)
-
-
-# CATEGORIES
-class Categories():
-
- # cats = bpy.context.scene.matlib.categories
-
- def __init__(self, cats):
- self.cats = cats
-
- def save(self):
- scn = bpy.context.scene
- cats = set([cat.name for cat in self.cats])
- libpath = bpy.context.scene.matlib.current_library.path
-
- cmd = """
-print(30*"+")
-import bpy
-if not hasattr(bpy.context.scene, "matlib_categories"):
- class EmptyProps(bpy.types.PropertyGroup):
- pass
- bpy.utils.register_class(EmptyProps)
- bpy.types.Scene.matlib_categories = bpy.props.CollectionProperty(type=EmptyProps)
-cats = bpy.context.scene.matlib_categories
-for cat in cats:
- cats.remove(0)
-"""
- for cat in cats:
- cmd += """
-cat = cats.add()
-cat.name = "%s" """ % cat.capitalize()
- cmd += '''
-bpy.ops.wm.save_mainfile(filepath="%s", check_existing=False, compress=True)''' % winpath(libpath)
-
- return send_command(cmd, "save_categories.py")
-
- def read(self, pull=True):
- # mandar a imprimir el listado
- catfile = winpath(os.path.join(matlib_path, "categories.txt"))
- cmd = """
-import bpy, json
-class EmptyProps(bpy.types.PropertyGroup):
- pass
-bpy.utils.register_class(EmptyProps)
-bpy.types.Scene.matlib_categories = bpy.props.CollectionProperty(type=EmptyProps)
-cats = []
-for cat in bpy.context.scene.matlib_categories:
- materials = []
- for mat in bpy.data.materials:
- if "category" in mat.keys() and mat['category'] == cat.name:
- materials.append(mat.name)
- cats.append([cat.name, materials])
-with open("%s", "w") as f:
- f.write(json.dumps(cats, sort_keys=True, indent=4))
-""" % catfile
- if pull:
- send_command(cmd)
-
- # leer el fichero
- with open(catfile, "r") as f:
- cats = json.loads(f.read())
-
- dd(cats)
- """
- # refrescar categorias
- for cat in self.cats:
- self.cats.remove(0)
-
- for cat in cats:
- item = self.cats.add()
- item.name = cat
- """
- return cats
-
- def view(self):
- for cat in self.cats:
- dd(cat.name)
-
- def add(self, name):
- if name and name not in [item.name for item in self.cats]:
- name = name.strip().capitalize()
- item = self.cats.add()
- item.name = name
- if self.save():
- dd(name, "added")
- return True
- else:
- dd("duplicated?")
-
- def remove(self, index):
- self.cats.remove(index)
- self.save()
-
-
-class Library():
-
- def __init__(self, name):
- self.name = name
- self.path = os.path.join(matlib_path, name)
- """
- @property
- def default(self):
- return self.name == default_library
- """
- @property
- def shortname(self):
- # if self.default:
- # return "Default Library"
- return bpy.path.display_name(self.name).title()
-
- def __repr__(self):
- return str(type(self).__name__) + "('" + self.name + "')"
-
-
-# bpy.utils.register_class(Library)
-
-def get_libraries():
- libs = [Library(f) for f in os.listdir(matlib_path) if f[-5::] == "blend"]
- return sorted(libs, key=lambda x: bpy.path.display_name(x.name))
-
-
-libraries = get_libraries()
-
-
-# MATLIB CLASS
-class matlibProperties(PropertyGroup):
-
- # MATLIB PROPERTIES
-
- # libraries are read from the xml
- lib_index = IntProperty(
- min=-1,
- default=-1,
- update=update_lib_index
- )
- all_materials = CollectionProperty(
- type=matlibMaterials
- )
- materials = CollectionProperty(
- type=matlibMaterials
- )
- mat_index = IntProperty(
- min=-1, default=-1
- )
- categories = CollectionProperty(
- type=EmptyGroup
- )
- cat_index = IntProperty(
- min=-1,
- default=-1,
- update=update_cat_index
- )
- search = StringProperty(
- name="Search",
- description="Find By Name",
- update=update_search_index
- )
-
- # MATLIB OPTIONS
- # link: import material linked
- # force import:
- # if disable it wont import a material if its present in the scene,(avoid duplicates)
- # instead it will apply the scene material rather than importing the same one from the library
- # filters: enable or disable category filter
- # last selected: store the last selected object to regain focus when apply a material.
- # hide_search: Hides Search Field
-
- link = BoolProperty(
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list