[Bf-extensions-cvs] [0ca01cc] master: matlibvx: revert ui changes
meta-androcto
noreply at git.blender.org
Tue Apr 25 06:55:36 CEST 2017
Commit: 0ca01cc32d5543ecb77c9a91cbdcfd37eaa07b43
Author: meta-androcto
Date: Tue Apr 25 14:55:11 2017 +1000
Branches: master
https://developer.blender.org/rBA0ca01cc32d5543ecb77c9a91cbdcfd37eaa07b43
matlibvx: revert ui changes
===================================================================
A materials_library_vx/README.txt
M materials_library_vx/__init__.py
===================================================================
diff --git a/materials_library_vx/README.txt b/materials_library_vx/README.txt
new file mode 100644
index 0000000..8a9b6cc
--- /dev/null
+++ b/materials_library_vx/README.txt
@@ -0,0 +1,75 @@
+# #####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 #####
+
+bl_info = {
+ "name": "Material Library",
+ "author": "Mackraken (mackraken2023 at hotmail.com)",
+ "version": (0, 5, 61),
+ "blender": (2, 7, 2),
+ "api": 60995,
+ "location": "Properties > Material",
+ "description": "Material Library VX",
+ "warning": "",
+ "wiki_url": "https://sites.google.com/site/aleonserra/home/scripts/matlib-vx",
+ "tracker_url": "",
+ "category": "System"}
+
+MATLIB 5.6.1
+
+Installation:
+- AVOID USING THE INSTALL ADDON BUTTON
+- Copy the matlib folder inside Blender's addons.
+Example: D:\Blender\2.72\scripts\addon\
+
+- Start Blender.
+- Goto File->User Preferences->Addons
+- Enable "Material Library"
+
+
+Updates:
+v 0.5.61
+- Libraries arent read on each draw call, only on startup or when added. This fixes potential crashes and is less stressful, but when a library is deleted blender should be restarted.
+-Moved the addon from "System" category to "Materials"
+
+v 0.5.6
+- Create new libraries.
+ Libraries are read from the matlib folder. If you want to change this behaviour, edit the variable "matlib_path" at line 40. (Untested)
+
+ To delete a library delete the blend file within the matlib folder.
+
+- Apply material to all selected objects.
+
+- Apply material in edit mesh mode.
+
+- Improved Material preview.
+ You can apply a material to the last selected object/s while you are previewing.
+
+- Categories are saved within the library blend file.
+
+- More warnings when things goes wrong.
+
+- Options Added:
+ - Force Import. False By default.
+ This option helps to avoid material duplicates when the same material its applied several times.
+ When this option is disabled the script will try to find the selected material within the working scene, instead of importing a new one from the library.
+ - Linked.
+ Import the material by making a link to the library.
+ - Hide search.
+ Shows or hides the search box.
+
+
diff --git a/materials_library_vx/__init__.py b/materials_library_vx/__init__.py
index 39bb55d..1556fb7 100644
--- a/materials_library_vx/__init__.py
+++ b/materials_library_vx/__init__.py
@@ -1,4 +1,4 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
+# #####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
@@ -14,1190 +14,1015 @@
# 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
+# #####END GPL LICENSE BLOCK #####
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"}
+ "name": "Material Library",
+ "author": "Mackraken (mackraken2023 at hotmail.com)",
+ "version": (0, 5, 6),
+ "blender": (2, 7, 2),
+ "api": 60995,
+ "location": "Properties > Material",
+ "description": "Material Library VX",
+ "warning": "",
+ "wiki_url": "https://sites.google.com/site/aleonserra/home/scripts/matlib-vx",
+ "tracker_url": "",
+ "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,
- )
+import bpy, os, json
+from bpy.props import *
+print (30*"-")
dev = False
+
matlib_path = os.path.dirname(__file__)
if dev:
- matlib_path = r"D:\Blender Foundation\Blender\2.72\scripts\addons\matlib"
-
+ matlib_path = r"D:\Blender Foundation\Blender\2.72\scripts\addons\matlib"
-# debug print variables
+##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
+ if dev:
+ if dodir:
+ print(dir(*args))
+ print(*args)
-
-# Regular Functions
+#Regular Functions
def winpath(path):
- return path.replace("\\", "\\\\")
-
-
+ 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
-
-
+ 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
-
+ #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()
-
+ self.load_library()
def update_cat_index(self, context):
- dd("cat index:", self.current_category, self.filters)
-
- if self.filters:
- self.filters = True
+ dd("cat index:", self.current_category, self.filter)
+ if self.filter:
+ self.filter = 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()
-
-
+
+ dd("filter:", self.filter, self.cat_index, self.current_category)
+# index = self.cat_index
+#
+# if self.filter:
+# cat = self.current_category
+# else:
+# cat = ""
+#
+# self.current_library.filter = cat
+ self.update_list()
+
def check_index(collection, index):
- count = len(collection)
- return count > 0 and index < count and index >= 0
-
+ 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)
-
-
+ bin = winpath(bpy.app.binary_path)
+ scriptpath = winpath(os.path.join(matlib_path, output))
+
+ with open(scriptpath, "w") as f:
+ f.write(cmd)
+
+ import subprocess
+
+ 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
-
-
+ 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(bpy.types.PropertyGroup):
+ pass
bpy.utils.register_class(EmptyGroup)
-
-class matlibMaterials(PropertyGroup):
- category = StringProperty()
-
-
+class matlibMaterials(bpy.types.PropertyGroup):
+ category = StringProperty()
bpy.utils.register_class(matlibMaterials)
+#bpy.types.Scene.matlib_categories = CollectionProperty(type=EmptyGroup)
-# bpy.types.Scene.matlib_categories = CollectionProperty(type=EmptyGroup)
-
-
-# CATEGORIES
+### CATEGORIES
class Categories():
-
- # cats = bpy.context.scene.matlib.categories
-
- def __init__(self,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list