diff options
author | lijenstina <lijenstina@gmail.com> | 2017-07-15 09:55:54 +0300 |
---|---|---|
committer | lijenstina <lijenstina@gmail.com> | 2017-07-15 09:55:54 +0300 |
commit | e93499db2ffc93f41d7374004f002b5b0813e1ad (patch) | |
tree | 58de113817a20c877a744352c74cca447b77ec50 /materials_utils/materials_cycles_converter.py | |
parent | 6e8234a541d477e560dea1cd3ab07a73bd3b8813 (diff) |
Fix T51618: Add a warning message override, poll check
Bumped version to 1.0.2
Add a poll for the bpy.app.path is not an empty string
that can happen if the file is not saved
Add and override to the warning_messages that will allow to
show up the message no matter what the setting is
Small UI fixes
Diffstat (limited to 'materials_utils/materials_cycles_converter.py')
-rw-r--r-- | materials_utils/materials_cycles_converter.py | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/materials_utils/materials_cycles_converter.py b/materials_utils/materials_cycles_converter.py index 55c57ba7..c9dd994d 100644 --- a/materials_utils/materials_cycles_converter.py +++ b/materials_utils/materials_cycles_converter.py @@ -5,22 +5,22 @@ import bpy from os import path as os_path from bpy.types import Operator -from math import (log2, - ceil, - ) +from math import ( + log2, ceil, + ) from bpy.props import ( - BoolProperty, - EnumProperty, - ) + BoolProperty, + EnumProperty, + ) from .warning_messages_utils import ( - warning_messages, - c_is_cycles_addon_enabled, - c_data_has_materials, - collect_report, - ) + warning_messages, + c_is_cycles_addon_enabled, + c_data_has_materials, + collect_report, + ) # ----------------------------------------------------------------------------- -# Globals # +# Globals # switch for operator's function called after AutoNodeInitiate CHECK_AUTONODE = False @@ -37,7 +37,7 @@ PAINT_SC_COLOR = (0.80, 0.75, 0.54, 0.9) CLAY_GLOSSY = (0.38, 0.032, 0.023, 1) # ----------------------------------------------------------------------------- -# Functions # +# Functions def AutoNodeSwitch(renderer="CYCLES", switch="OFF", operator=None): @@ -130,8 +130,7 @@ def BakingText(tex, mode, tex_type=None): img = bpy.data.images.get("TMP_BAKING") img.file_format = ("JPEG" if not mode == "ALPHA" else "PNG") - # switch temporarly to 'IMAGE EDITOR' - # other approaches are not reliable + # switch temporarly to 'IMAGE EDITOR', other approaches are not reliable check_area = False store_area = bpy.context.area.type collect_report("INFO: Temporarly switching context to Image Editor") @@ -211,7 +210,7 @@ def AutoNodeInitiate(active=False, operator=None): if sc.mat_specials.SET_FAKE_USER: SetFakeUserTex() else: - warning_messages(operator, 'DIR_PATH_CONVERT') + warning_messages(operator, 'DIR_PATH_CONVERT', override=True) def AutoNode(active=False, operator=None): @@ -850,7 +849,7 @@ def create_mix_node(TreeNodes, links, nodes, loc, start, median_point, row, fram # ----------------------------------------------------------------------------- -# Operator Classes # +# Operator Classes class mllock(Operator): bl_idname = "ml.lock" @@ -877,12 +876,14 @@ class mllock(Operator): class mlrefresh(Operator): bl_idname = "ml.refresh" bl_label = "Convert All Materials" - bl_description = "Convert All Materials in the scene from non-nodes to Cycles" + bl_description = ("Convert All Materials in the scene from non-nodes to Cycles\n" + "Needs saving the .blend file first") bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): - return (c_is_cycles_addon_enabled() and c_data_has_materials()) + return (bpy.data.filepath != ""and c_is_cycles_addon_enabled() and + c_data_has_materials()) def execute(self, context): AutoNodeInitiate(False, self) @@ -909,13 +910,14 @@ class mlrefresh(Operator): class mlrefresh_active(Operator): bl_idname = "ml.refresh_active" bl_label = "Convert All Materials From Active Object" - bl_description = "Convert all Active Object's Materials from non-nodes to Cycles" + bl_description = ("Convert all Active Object's Materials from non-nodes to Cycles\n" + "Needs saving the .blend file first") bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): - return (c_is_cycles_addon_enabled() and c_data_has_materials() and - context.active_object is not None) + return (bpy.data.filepath != "" and c_is_cycles_addon_enabled() and + c_data_has_materials() and context.active_object is not None) def execute(self, context): AutoNodeInitiate(True, self) @@ -978,5 +980,6 @@ def unregister(): bpy.utils.unregister_module(__name__) pass + if __name__ == "__main__": register() |