Merge branch 'master' into blender2.8

This commit is contained in:
Campbell Barton
2017-03-25 13:49:13 +11:00
28 changed files with 1247 additions and 150 deletions

View File

@@ -21,7 +21,10 @@ import bpy
import os
from bpy.types import Operator
from bpy.props import FloatProperty
from mathutils import Vector, Matrix
from mathutils import (
Vector,
Matrix,
)
def CLIP_spaces_walk(context, all_screens, tarea, tspace, callback, *args):
@@ -1084,4 +1087,4 @@ classes = (
CLIP_OT_track_settings_as_default,
CLIP_OT_track_settings_to_track,
CLIP_OT_track_to_empty,
)
)

View File

@@ -16,13 +16,15 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
from bpy.props import (
BoolProperty,
EnumProperty,
StringProperty,
)
BoolProperty,
EnumProperty,
StringProperty,
)
class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):

View File

@@ -21,7 +21,10 @@
import bpy
from bpy.types import Operator
from bpy.props import EnumProperty, IntProperty
from bpy.props import (
EnumProperty,
IntProperty,
)
class MeshMirrorUV(Operator):
@@ -254,4 +257,4 @@ classes = (
MeshMirrorUV,
MeshSelectNext,
MeshSelectPrev,
)
)

View File

@@ -21,16 +21,16 @@
import bpy
import nodeitems_utils
from bpy.types import (
Operator,
PropertyGroup,
)
Operator,
PropertyGroup,
)
from bpy.props import (
BoolProperty,
CollectionProperty,
EnumProperty,
IntProperty,
StringProperty,
)
BoolProperty,
CollectionProperty,
EnumProperty,
IntProperty,
StringProperty,
)
class NodeSetting(PropertyGroup):

View File

@@ -21,12 +21,12 @@
import bpy
from bpy.types import Operator
from bpy.props import (
StringProperty,
BoolProperty,
EnumProperty,
IntProperty,
FloatProperty,
)
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
StringProperty,
)
class SelectPattern(Operator):
@@ -1054,4 +1054,4 @@ classes = (
SubdivisionSet,
TransformsToDeltas,
TransformsToDeltasAnim,
)
)

View File

@@ -26,13 +26,14 @@ from mathutils import Vector
def GlobalBB_LQ(bb_world):
# Initialize the variables with the 8th vertex
left, right, front, back, down, up = (bb_world[7][0],
bb_world[7][0],
bb_world[7][1],
bb_world[7][1],
bb_world[7][2],
bb_world[7][2],
)
left, right, front, back, down, up = (
bb_world[7][0],
bb_world[7][0],
bb_world[7][1],
bb_world[7][1],
bb_world[7][2],
bb_world[7][2],
)
# Test against the other 7 verts
for i in range(7):
@@ -398,13 +399,15 @@ class AlignObjects(Operator):
def execute(self, context):
align_axis = self.align_axis
ret = align_objects(context,
'X' in align_axis,
'Y' in align_axis,
'Z' in align_axis,
self.align_mode,
self.relative_to,
self.bb_quality)
ret = align_objects(
context,
'X' in align_axis,
'Y' in align_axis,
'Z' in align_axis,
self.align_mode,
self.relative_to,
self.bb_quality,
)
if not ret:
self.report({'WARNING'}, "No objects with bound-box selected")
@@ -415,4 +418,4 @@ class AlignObjects(Operator):
classes = (
AlignObjects,
)
)

View File

@@ -22,12 +22,12 @@ from mathutils import Vector
import bpy
from bpy.types import Operator
from bpy.props import (
BoolProperty,
EnumProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
)
BoolProperty,
EnumProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
)
def object_ensure_material(obj, mat_name):
@@ -652,4 +652,4 @@ classes = (
QuickFluid,
QuickFur,
QuickSmoke,
)
)

View File

@@ -20,8 +20,10 @@
import bpy
from bpy.types import Operator
from bpy.props import IntProperty
from bpy.props import EnumProperty
from bpy.props import (
EnumProperty,
IntProperty,
)
class CopyRigidbodySettings(Operator):
@@ -315,4 +317,4 @@ classes = (
BakeToKeyframes,
ConnectRigidBodies,
CopyRigidbodySettings,
)
)

View File

@@ -18,7 +18,11 @@
# TODO <pep8 compliant>
from mathutils import Matrix, Vector, geometry
from mathutils import (
Matrix,
Vector,
geometry,
)
import bpy
from bpy.types import Operator
@@ -1104,4 +1108,4 @@ class SmartProject(Operator):
classes = (
SmartProject,
)
)

View File

@@ -21,12 +21,12 @@
import bpy
from bpy.types import Operator
from bpy.props import (
StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
EnumProperty,
)
StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
EnumProperty,
)
from bpy.app.translations import pgettext_tip as tip_
@@ -130,6 +130,20 @@ def execute_context_assign(self, context):
return operator_path_undo_return(context, data_path)
def module_filesystem_remove(path_base, module_name):
import os
module_name = os.path.splitext(module_name)[0]
for f in os.listdir(path_base):
f_base = os.path.splitext(f)[0]
if f_base == module_name:
f_full = os.path.join(path_base, f)
if os.path.isdir(f_full):
os.rmdir(f_full)
else:
os.remove(f_full)
class BRUSH_OT_active_index_set(Operator):
"""Set active sculpt/paint brush from it's number"""
bl_idname = "brush.active_index_set"
@@ -907,7 +921,10 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
# an operator (common case - just button referencing an op)
if hasattr(bpy.types, class_name.upper() + "_OT_" + class_prop):
if do_url:
url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" % (url_prefix, class_name, class_name, class_prop))
url = (
"%s/bpy.ops.%s.html#bpy.ops.%s.%s" %
(url_prefix, class_name, class_name, class_prop)
)
else:
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
else:
@@ -922,7 +939,10 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
class_name, class_prop = class_name.split("_OT_", 1)
class_name = class_name.lower()
if do_url:
url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" % (url_prefix, class_name, class_name, class_prop))
url = (
"%s/bpy.ops.%s.html#bpy.ops.%s.%s" %
(url_prefix, class_name, class_name, class_prop)
)
else:
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
else:
@@ -938,9 +958,12 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
rna_parent = rna_parent.base
if do_url:
url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" % (url_prefix, class_name, class_name, class_prop))
url = (
"%s/bpy.types.%s.html#bpy.types.%s.%s" %
(url_prefix, class_name, class_name, class_prop)
)
else:
rna = ("bpy.types.%s.%s" % (class_name, class_prop))
rna = "bpy.types.%s.%s" % (class_name, class_prop)
else:
# We assume this is custom property, only try to generate generic url/rna_id...
if do_url:
@@ -1087,10 +1110,10 @@ class WM_OT_properties_edit(Operator):
def execute(self, context):
from rna_prop_ui import (
rna_idprop_ui_prop_get,
rna_idprop_ui_prop_clear,
rna_idprop_ui_prop_update,
)
rna_idprop_ui_prop_get,
rna_idprop_ui_prop_clear,
rna_idprop_ui_prop_update,
)
data_path = self.data_path
value = self.value
@@ -1267,9 +1290,9 @@ class WM_OT_properties_add(Operator):
def execute(self, context):
from rna_prop_ui import (
rna_idprop_ui_prop_get,
rna_idprop_ui_prop_update,
)
rna_idprop_ui_prop_get,
rna_idprop_ui_prop_update,
)
data_path = self.data_path
item = eval("context.%s" % data_path)
@@ -1284,10 +1307,10 @@ class WM_OT_properties_add(Operator):
return prop_new
prop = unique_name(
{*item.keys(),
*type(item).bl_rna.properties.keys(),
})
prop = unique_name({
*item.keys(),
*type(item).bl_rna.properties.keys(),
})
item[prop] = 1.0
rna_idprop_ui_prop_update(item, prop)
@@ -1327,9 +1350,9 @@ class WM_OT_properties_remove(Operator):
def execute(self, context):
from rna_prop_ui import (
rna_idprop_ui_prop_clear,
rna_idprop_ui_prop_update,
)
rna_idprop_ui_prop_clear,
rna_idprop_ui_prop_update,
)
data_path = self.data_path
item = eval("context.%s" % data_path)
prop = self.property
@@ -1367,7 +1390,10 @@ class WM_OT_appconfig_default(Operator):
filepath = os.path.join(bpy.utils.preset_paths("interaction")[0], "blender.py")
if os.path.exists(filepath):
bpy.ops.script.execute_preset(filepath=filepath, menu_idname="USERPREF_MT_interaction_presets")
bpy.ops.script.execute_preset(
filepath=filepath,
menu_idname="USERPREF_MT_interaction_presets",
)
return {'FINISHED'}
@@ -1387,7 +1413,10 @@ class WM_OT_appconfig_activate(Operator):
filepath = self.filepath.replace("keyconfig", "interaction")
if os.path.exists(filepath):
bpy.ops.script.execute_preset(filepath=filepath, menu_idname="USERPREF_MT_interaction_presets")
bpy.ops.script.execute_preset(
filepath=filepath,
menu_idname="USERPREF_MT_interaction_presets",
)
return {'FINISHED'}
@@ -1492,7 +1521,7 @@ class WM_OT_blenderplayer_start(Operator):
"-g", "show_profile", "=", "%d" % gs.show_framerate_profile,
"-g", "show_properties", "=", "%d" % gs.show_debug_properties,
"-g", "ignore_deprecation_warnings", "=", "%d" % (not gs.use_deprecation_warnings),
])
])
# finish the call with the path to the blend file
args.append(filepath)
@@ -1622,10 +1651,11 @@ class WM_OT_keyconfig_export(Operator):
wm = context.window_manager
keyconfig_utils.keyconfig_export(wm,
wm.keyconfigs.active,
self.filepath,
)
keyconfig_utils.keyconfig_export(
wm,
wm.keyconfigs.active,
self.filepath,
)
return {'FINISHED'}
@@ -1890,7 +1920,10 @@ class WM_OT_theme_install(Operator):
try:
shutil.copyfile(xmlfile, path_dest)
bpy.ops.script.execute_preset(filepath=path_dest, menu_idname="USERPREF_MT_interface_theme_presets")
bpy.ops.script.execute_preset(
filepath=path_dest,
menu_idname="USERPREF_MT_interface_theme_presets",
)
except:
traceback.print_exc()
@@ -1917,10 +1950,12 @@ class WM_OT_addon_refresh(Operator):
return {'FINISHED'}
# Note: shares some logic with WM_OT_app_template_install
# but not enough to de-duplicate. Fixed here may apply to both.
class WM_OT_addon_install(Operator):
"Install an add-on"
bl_idname = "wm.addon_install"
bl_label = "Install from File..."
bl_label = "Install Add-on from File..."
overwrite = BoolProperty(
name="Overwrite",
@@ -1951,20 +1986,6 @@ class WM_OT_addon_install(Operator):
options={'HIDDEN'},
)
@staticmethod
def _module_remove(path_addons, module):
import os
module = os.path.splitext(module)[0]
for f in os.listdir(path_addons):
f_base = os.path.splitext(f)[0]
if f_base == module:
f_full = os.path.join(path_addons, f)
if os.path.isdir(f_full):
os.rmdir(f_full)
else:
os.remove(f_full)
def execute(self, context):
import addon_utils
import traceback
@@ -2017,7 +2038,7 @@ class WM_OT_addon_install(Operator):
if self.overwrite:
for f in file_to_extract.namelist():
WM_OT_addon_install._module_remove(path_addons, f)
module_filesystem_remove(path_addons, f)
else:
for f in file_to_extract.namelist():
path_dest = os.path.join(path_addons, os.path.basename(f))
@@ -2035,7 +2056,7 @@ class WM_OT_addon_install(Operator):
path_dest = os.path.join(path_addons, os.path.basename(pyfile))
if self.overwrite:
WM_OT_addon_install._module_remove(path_addons, os.path.basename(pyfile))
module_filesystem_remove(path_addons, os.path.basename(pyfile))
elif os.path.exists(path_dest):
self.report({'WARNING'}, "File already installed to %r\n" % path_dest)
return {'CANCELLED'}
@@ -2070,7 +2091,10 @@ class WM_OT_addon_install(Operator):
bpy.utils.refresh_script_paths()
# print message
msg = tip_("Modules Installed from %r into %r (%s)") % (pyfile, path_addons, ", ".join(sorted(addons_new)))
msg = (
tip_("Modules Installed (%s) from %r into %r (%s)") %
(", ".join(sorted(addons_new)), pyfile, path_addons)
)
print(msg)
self.report({'INFO'}, msg)
@@ -2164,6 +2188,7 @@ class WM_OT_addon_expand(Operator):
return {'FINISHED'}
class WM_OT_addon_userpref_show(Operator):
"Show add-on user preferences"
bl_idname = "wm.addon_userpref_show"
@@ -2194,6 +2219,123 @@ class WM_OT_addon_userpref_show(Operator):
return {'FINISHED'}
# Note: shares some logic with WM_OT_addon_install
# but not enough to de-duplicate. Fixes here may apply to both.
class WM_OT_app_template_install(Operator):
"Install an application-template"
bl_idname = "wm.app_template_install"
bl_label = "Install Template from File..."
overwrite = BoolProperty(
name="Overwrite",
description="Remove existing template with the same ID",
default=True,
)
filepath = StringProperty(
subtype='FILE_PATH',
)
filter_folder = BoolProperty(
name="Filter folders",
default=True,
options={'HIDDEN'},
)
filter_python = BoolProperty(
name="Filter python",
default=True,
options={'HIDDEN'},
)
filter_glob = StringProperty(
default="*.py;*.zip",
options={'HIDDEN'},
)
def execute(self, context):
import traceback
import zipfile
import shutil
import os
pyfile = self.filepath
path_app_templates = bpy.utils.user_resource(
'SCRIPTS', os.path.join("startup", "bl_app_templates_user"),
create=True,
)
if not path_app_templates:
self.report({'ERROR'}, "Failed to get add-ons path")
return {'CANCELLED'}
if not os.path.isdir(path_app_templates):
try:
os.makedirs(path_app_templates, exist_ok=True)
except:
traceback.print_exc()
app_templates_old = set(os.listdir(path_app_templates))
# check to see if the file is in compressed format (.zip)
if zipfile.is_zipfile(pyfile):
try:
file_to_extract = zipfile.ZipFile(pyfile, 'r')
except:
traceback.print_exc()
return {'CANCELLED'}
if self.overwrite:
for f in file_to_extract.namelist():
module_filesystem_remove(path_app_templates, f)
else:
for f in file_to_extract.namelist():
path_dest = os.path.join(path_app_templates, os.path.basename(f))
if os.path.exists(path_dest):
self.report({'WARNING'}, "File already installed to %r\n" % path_dest)
return {'CANCELLED'}
try: # extract the file to "bl_app_templates_user"
file_to_extract.extractall(path_app_templates)
except:
traceback.print_exc()
return {'CANCELLED'}
else:
path_dest = os.path.join(path_app_templates, os.path.basename(pyfile))
if self.overwrite:
module_filesystem_remove(path_app_templates, os.path.basename(pyfile))
elif os.path.exists(path_dest):
self.report({'WARNING'}, "File already installed to %r\n" % path_dest)
return {'CANCELLED'}
# if not compressed file just copy into the addon path
try:
shutil.copyfile(pyfile, path_dest)
except:
traceback.print_exc()
return {'CANCELLED'}
app_templates_new = set(os.listdir(path_app_templates)) - app_templates_old
# in case a new module path was created to install this addon.
bpy.utils.refresh_script_paths()
# print message
msg = (
tip_("Template Installed (%s) from %r into %r") %
(", ".join(sorted(app_templates_new)), pyfile, path_app_templates)
)
print(msg)
self.report({'INFO'}, msg)
return {'FINISHED'}
def invoke(self, context, event):
wm = context.window_manager
wm.fileselect_add(self)
return {'RUNNING_MODAL'}
classes = (
BRUSH_OT_active_index_set,
WM_OT_addon_disable,
@@ -2203,6 +2345,7 @@ classes = (
WM_OT_addon_refresh,
WM_OT_addon_remove,
WM_OT_addon_userpref_show,
WM_OT_app_template_install,
WM_OT_appconfig_activate,
WM_OT_appconfig_default,
WM_OT_blenderplayer_start,
@@ -2246,4 +2389,4 @@ classes = (
WM_OT_sysinfo,
WM_OT_theme_install,
WM_OT_url_open,
)
)