[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4035] contrib/py/scripts/addons/ online_mat_lib: Fixed some bugs and improved a couple small things.
Peter Cassetta
peter at fingertipsoft.com
Tue Dec 11 09:09:07 CET 2012
Revision: 4035
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4035
Author: petercassetta
Date: 2012-12-11 08:09:05 +0000 (Tue, 11 Dec 2012)
Log Message:
-----------
Fixed some bugs and improved a couple small things.
Modified Paths:
--------------
contrib/py/scripts/addons/online_mat_lib/__init__.py
contrib/py/scripts/addons/online_mat_lib/material-library/bundled/cycles/index.xml
Modified: contrib/py/scripts/addons/online_mat_lib/__init__.py
===================================================================
--- contrib/py/scripts/addons/online_mat_lib/__init__.py 2012-12-10 11:06:08 UTC (rev 4034)
+++ contrib/py/scripts/addons/online_mat_lib/__init__.py 2012-12-11 08:09:05 UTC (rev 4035)
@@ -46,11 +46,6 @@
import xml.dom.minidom
library = ""
-#editions = [("Release0", "Release", "(recommended) Stable; gets updated with high-quality materials every one or two months."),
-# ("Testing1", "Testing", "(online only) Volatile; gets updated with new materials continually."),
-# ("Bundled2", "Bundled", "(offline only) Contains a small amount of materials bundled with this add-on.")]
-#bpy.types.Scene.mat_lib_edition = bpy.props.EnumProperty(name = "Library Edition", items = editions, description = "Choose an edition", options = {'SKIP_SAVE'})
-
library_data = []
update_data = ["Up-to-date.", ""]
@@ -63,12 +58,14 @@
mat_lib_host = ""
mat_lib_location = ""
mat_lib_cached_files = -1
-if os.path.exists(bpy.utils.user_resource('SCRIPTS', path="addons" + os.sep + "online_mat_lib" + os.sep + "material-library")):
- mat_lib_folder = bpy.utils.user_resource('SCRIPTS', path="addons" + os.sep + "online_mat_lib" + os.sep + "material-library")
-elif os.path.exists(bpy.utils.script_paths()[0] + os.sep + "addons" + os.sep + "online_mat_lib" + os.sep + "material-library"):
- mat_lib_folder = bpy.utils.script_paths()[0] + os.sep + "addons" + os.sep + "online_mat_lib" + os.sep + "material-library"
-elif bpy.utils.script_paths()[0] + os.sep + "addons_contrib" + os.sep + "online_mat_lib" + os.sep + "material-library":
- mat_lib_folder = bpy.utils.script_paths()[0] + os.sep + "addons_contrib" + os.sep + "online_mat_lib" + os.sep + "material-library"
+if os.path.exists(os.path.join(bpy.context.user_preferences.filepaths.script_directory, "addons", "online_mat_lib", "material-library")):
+ mat_lib_folder = os.path.join(bpy.context.user_preferences.filepaths.script_directory, "addons", "online_mat_lib", "material-library")
+elif os.path.exists(os.path.join(bpy.utils.script_path_user(), "addons", "online_mat_lib", "material-library")):
+ mat_lib_folder = os.path.join(bpy.utils.script_path_user(), "addons", "online_mat_lib", "material-library")
+elif os.path.exists(os.path.join(bpy.utils.script_paths()[0], "addons", "online_mat_lib", "material-library")):
+ mat_lib_folder = os.path.join(bpy.utils.script_paths()[0], "addons", "online_mat_lib", "material-library")
+elif os.path.exists(os.path.join(bpy.utils.script_paths()[0], "addons_contrib", "online_mat_lib", "material-library")):
+ mat_lib_folder = os.path.join(bpy.utils.script_paths()[0], "addons_contrib", "online_mat_lib", "material-library")
else:
print("ONLINE MATERIAL LIBRARY -- MAJOR PROBLEM:"\
"COULD NOT LOCATE ADD-ON INSTALLATION PATH.")
@@ -269,8 +266,10 @@
row = layout.row()
if mat_lib_cached_files == 0:
row.label(text="No cached files.")
+ elif mat_lib_cached_files == -2:
+ row.label(text="The Bundled library contains no cached files.")
elif mat_lib_cached_files == 1:
- row.label(text=str(mat_lib_cached_files) + " cached file.")
+ row.label(text="1 cached file.")
row.operator("material.libraryclearcache", text="Clear Cache", icon='CANCEL')
elif mat_lib_cached_files != -1:
row.label(text=str(mat_lib_cached_files) + " cached files.")
@@ -1154,6 +1153,7 @@
if library == "":
return {'FINISHED'}
elif library == "bundled":
+ mat_lib_cached_files = -2
return {'FINISHED'}
elif library == "composite":
cached_data_path = mat_lib_folder + os.sep + mat_lib_host + os.sep + "cycles" + os.sep
@@ -1504,7 +1504,7 @@
#Check if has texture
if bpy.data.images.find("mat_lib_preview_image.jpg") == -1:
- bpy.ops.image.open(filepath=mat_lib_folder + os.sep + "mat_lib_preview_image.jpg")
+ bpy.ops.image.open(filepath=os.path.join(mat_lib_folder, "mat_lib_preview_image.jpg"))
if "mat_lib_preview_texture" not in bpy.data.textures:
bpy.data.textures.new("mat_lib_preview_texture", "IMAGE")
@@ -1512,6 +1512,9 @@
if bpy.data.textures["mat_lib_preview_texture"].image != bpy.data.images["mat_lib_preview_image.jpg"]:
bpy.data.textures["mat_lib_preview_texture"].image = bpy.data.images["mat_lib_preview_image.jpg"]
+ if bpy.data.images["mat_lib_preview_image.jpg"].filepath != os.path.join(mat_lib_folder, "mat_lib_preview_image.jpg"):
+ bpy.data.images["mat_lib_preview_image.jpg"].filepath != os.path.join(mat_lib_folder, "mat_lib_preview_image.jpg")
+
#Do everything possible to get Blender to reload the preview.
bpy.data.images["mat_lib_preview_image.jpg"].reload()
bpy.ops.wm.redraw_timer()
@@ -2933,7 +2936,7 @@
print ("SCRIPT")
node = node_tree.nodes.new(node_type)
node.mode = node_data['mode'].value
- if node_data['mode'] == 'EXTERNAL':
+ if node_data['mode'].value == 'EXTERNAL':
if 'script' in node_data:
if "file://" in node_data['script'].value:
node.filepath = node_data['script'].value[7:]
Modified: contrib/py/scripts/addons/online_mat_lib/material-library/bundled/cycles/index.xml
===================================================================
--- contrib/py/scripts/addons/online_mat_lib/material-library/bundled/cycles/index.xml 2012-12-10 11:06:08 UTC (rev 4034)
+++ contrib/py/scripts/addons/online_mat_lib/material-library/bundled/cycles/index.xml 2012-12-11 08:09:05 UTC (rev 4035)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<library>
<category title="Car Paint" folder="car-paint" addon="0.4">
- <material name="Basic Blue" href="basic_blue" stars="3" addon="0.4" />
<material name="Dull Coral" href="dull_coral" by="monsterdog" stars="4" addon="0.4" />
<material name="Dull Olive" href="dull_olive" stars="5" addon="0.4" />
<material name="Flaky Green" href="flaky_green" stars="5" fireflies="medium" addon="0.4" />
@@ -41,7 +40,6 @@
<category title="Nature" folder="nature" addon="0.4">
<material name="Pearl" href="pearl" by="moony" stars="4" addon="0.4" />
<material name="Forest" href="forest" by="Jonathan L" stars="4" complexity="complex" addon="0.4" />
- <material name="Lava" href="lava" by="monsterdog" stars="4" complexity="intermediate" addon="0.4" />
</category>
<category title="Plastics" folder="plastics" addon="0.4">
<material name="Toy Brick (Red)" href="toy_brick_red" by="Peter Cassetta" stars="4" addon="0.4" />
More information about the Bf-extensions-cvs
mailing list