Python addon_utils.check() Examples

The following are 19 code examples of addon_utils.check(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module addon_utils , or try the search function .
Example #1
Source File: bl_extract_messages.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def process_msg(msgs, msgctxt, msgid, msgsrc, reports, check_ctxt, settings):
    if filter_message(msgid):
        reports["messages_skipped"].add((msgid, msgsrc))
        return
    if not msgctxt:
        # We do *not* want any "" context!
        msgctxt = settings.DEFAULT_CONTEXT
    # Always unescape keys!
    msgctxt = utils.I18nMessage.do_unescape(msgctxt)
    msgid = utils.I18nMessage.do_unescape(msgid)
    key = (msgctxt, msgid)
    check(check_ctxt, msgs, key, msgsrc, settings)
    msgsrc = settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM + msgsrc
    if key not in msgs:
        msgs[key] = utils.I18nMessage([msgctxt], [msgid], [], [msgsrc], settings=settings)
    else:
        msgs[key].comment_lines.append(msgsrc)


##### RNA ##### 
Example #2
Source File: pbaker_prefs.py    From Principled-Baker with GNU General Public License v3.0 6 votes vote down vote up
def draw(self, context):
        layout = self.layout
        col = layout.column()

        # 2.80
        if bpy.app.version_string.startswith('2.8'):
            col.prop(self, "switch_to_cycles")
            col.label(text="This may crash Blender!", icon='ERROR')
            col.separator()

        col.prop(self, "mat_id_algorithm")
        if self.mat_id_algorithm == 'HUE':
            col.prop(self, "mat_id_saturation")
            col.prop(self, "mat_id_value")
        elif self.mat_id_algorithm == 'NAME':
            self.layout.label(
                text="Duplicate colors are possible!", icon='ERROR')

        # # Node Wrangler for Texture Setup
        # if check("node_wrangler"):
        #     col.prop(self, "use_node_wrangler") 
Example #3
Source File: bl_extract_messages.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def process_msg(msgs, msgctxt, msgid, msgsrc, reports, check_ctxt, settings):
    if filter_message(msgid):
        reports["messages_skipped"].add((msgid, msgsrc))
        return
    if not msgctxt:
        # We do *not* want any "" context!
        msgctxt = settings.DEFAULT_CONTEXT
    # Always unescape keys!
    msgctxt = utils.I18nMessage.do_unescape(msgctxt)
    msgid = utils.I18nMessage.do_unescape(msgid)
    key = (msgctxt, msgid)
    check(check_ctxt, msgs, key, msgsrc, settings)
    msgsrc = settings.PO_COMMENT_PREFIX_SOURCE_CUSTOM + msgsrc
    if key not in msgs:
        msgs[key] = utils.I18nMessage([msgctxt], [msgid], [], [msgsrc], settings=settings)
    else:
        msgs[key].comment_lines.append(msgsrc)


##### RNA ##### 
Example #4
Source File: importer.py    From cats-blender-plugin with MIT License 6 votes vote down vote up
def execute(self, context):
        Common.remove_unused_objects()

        # Make sure that the first layer is visible
        if hasattr(context.scene, 'layers'):
            context.scene.layers[0] = True

        # Enable fbx if it isn't enabled yet
        fbx_is_enabled = addon_utils.check('io_scene_fbx')[1]
        if not fbx_is_enabled:
            addon_utils.enable('io_scene_fbx')

        try:
            bpy.ops.import_scene.fbx('INVOKE_DEFAULT',
                                     automatic_bone_orientation=False,
                                     use_prepost_rot=False,
                                     use_anim=False)
        except (TypeError, ValueError):
            bpy.ops.import_scene.fbx('INVOKE_DEFAULT')

        return {'FINISHED'} 
Example #5
Source File: atlas.py    From cats-blender-plugin with MIT License 5 votes vote down vote up
def check(self, context):
        # Important for changing options
        return True 
Example #6
Source File: importer.py    From cats-blender-plugin with MIT License 5 votes vote down vote up
def check(self, context):
        # Important for changing options
        return True 
Example #7
Source File: importer.py    From cats-blender-plugin with MIT License 5 votes vote down vote up
def check(self, context):
        # Important for changing options
        return True 
Example #8
Source File: importer.py    From cats-blender-plugin with MIT License 5 votes vote down vote up
def check(self, context):
        # Important for changing options
        return True 
Example #9
Source File: importer.py    From cats-blender-plugin with MIT License 5 votes vote down vote up
def check(self, context):
        # Important for changing options
        return True 
Example #10
Source File: importer.py    From cats-blender-plugin with MIT License 5 votes vote down vote up
def check(self, context):
        # Important for changing options
        return False 
Example #11
Source File: importer.py    From cats-blender-plugin with MIT License 5 votes vote down vote up
def execute(self, context):
        # Save all current objects to check which armatures got added by the importer
        pre_import_objects = [obj for obj in bpy.data.objects if obj.type == 'ARMATURE']

        # Import the file
        ImportAnyModel.extract_file()

        # Create list of armatures that got added during import, select them in cats and fix their bone orientations if necessary
        fix_armatures_post_import(pre_import_objects)

        return {'FINISHED'} 
Example #12
Source File: __init__.py    From Blender-For-UnrealEngine-Addons with GNU General Public License v3.0 5 votes vote down vote up
def check(self, context):
			return True 
Example #13
Source File: optimization.py    From cats-blender-plugin with MIT License 5 votes vote down vote up
def check_for_smc():
    global draw_smc_ui, old_smc_version, smc_is_disabled, found_very_old_smc

    draw_smc_ui = None
    found_very_old_smc = False

    for mod in addon_utils.modules():
        if mod.bl_info['name'] == "Shotariya-don":
            if hasattr(bpy.context.scene, 'shotariya_tex_idx'):
                found_very_old_smc = True
            continue
        if mod.bl_info['name'] == "Shotariya's Material Combiner":
            # print(mod.__name__, mod.bl_info['version'])
            # print(addon_utils.check(mod.__name__))
            if mod.bl_info['version'] < (2, 1, 1, 2):
                old_smc_version = True
                # print('TOO OLD!')
                continue
            if not addon_utils.check(mod.__name__)[0]:
                smc_is_disabled = True
                # print('DISABLED!')
                continue

            # print('FOUND!')
            old_smc_version = False
            smc_is_disabled = False
            found_very_old_smc = False
            draw_smc_ui = getattr(import_module(mod.__name__ + '.operators.ui.include'), 'draw_ui')
            break


# @register_wrap
# class AtlasList(bpy.types.UIList):
#     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
#         mat = item.material
#         row = layout.row()
#         row.prop(mat, 'name', emboss=False, text='', icon_value=layout.icon(mat))
#         sub_row = row.row()
#         sub_row.scale_x = 0.2
#         row.prop(mat, 'add_to_atlas', text='') 
Example #14
Source File: bl_extract_messages.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def check(check_ctxt, msgs, key, msgsrc, settings):
    """
    Performs a set of checks over the given key (context, message)...
    """
    if check_ctxt is None:
        return
    multi_rnatip = check_ctxt.get("multi_rnatip")
    multi_lines = check_ctxt.get("multi_lines")
    py_in_rna = check_ctxt.get("py_in_rna")
    not_capitalized = check_ctxt.get("not_capitalized")
    end_point = check_ctxt.get("end_point")
    undoc_ops = check_ctxt.get("undoc_ops")
    spell_checker = check_ctxt.get("spell_checker")
    spell_errors = check_ctxt.get("spell_errors")

    if multi_rnatip is not None:
        if key in msgs and key not in multi_rnatip:
            multi_rnatip.add(key)
    if multi_lines is not None:
        if '\n' in key[1]:
            multi_lines.add(key)
    if py_in_rna is not None:
        if key in py_in_rna[1]:
            py_in_rna[0].add(key)
    if not_capitalized is not None:
        if(key[1] not in settings.WARN_MSGID_NOT_CAPITALIZED_ALLOWED and
           key[1][0].isalpha() and not key[1][0].isupper()):
            not_capitalized.add(key)
    if end_point is not None:
        if (key[1].strip().endswith('.') and not key[1].strip().endswith('...') and
            key[1] not in settings.WARN_MSGID_END_POINT_ALLOWED):
            end_point.add(key)
    if undoc_ops is not None:
        if key[1] == settings.UNDOC_OPS_STR:
            undoc_ops.add(key)
    if spell_checker is not None and spell_errors is not None:
        err = spell_checker.check(key[1])
        if err:
            spell_errors[key] = err 
Example #15
Source File: bl_extract_messages.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def check(check_ctxt, msgs, key, msgsrc, settings):
    """
    Performs a set of checks over the given key (context, message)...
    """
    if check_ctxt is None:
        return
    multi_rnatip = check_ctxt.get("multi_rnatip")
    multi_lines = check_ctxt.get("multi_lines")
    py_in_rna = check_ctxt.get("py_in_rna")
    not_capitalized = check_ctxt.get("not_capitalized")
    end_point = check_ctxt.get("end_point")
    undoc_ops = check_ctxt.get("undoc_ops")
    spell_checker = check_ctxt.get("spell_checker")
    spell_errors = check_ctxt.get("spell_errors")

    if multi_rnatip is not None:
        if key in msgs and key not in multi_rnatip:
            multi_rnatip.add(key)
    if multi_lines is not None:
        if '\n' in key[1]:
            multi_lines.add(key)
    if py_in_rna is not None:
        if key in py_in_rna[1]:
            py_in_rna[0].add(key)
    if not_capitalized is not None:
        if(key[1] not in settings.WARN_MSGID_NOT_CAPITALIZED_ALLOWED and
           key[1][0].isalpha() and not key[1][0].isupper()):
            not_capitalized.add(key)
    if end_point is not None:
        if (key[1].strip().endswith('.') and not key[1].strip().endswith('...') and
            key[1] not in settings.WARN_MSGID_END_POINT_ALLOWED):
            end_point.add(key)
    if undoc_ops is not None:
        if key[1] == settings.UNDOC_OPS_STR:
            undoc_ops.add(key)
    if spell_checker is not None and spell_errors is not None:
        err = spell_checker.check(key[1])
        if err:
            spell_errors[key] = err 
Example #16
Source File: op_REMESHERS_POST.py    From BakeMyScan with GNU General Public License v3.0 5 votes vote down vote up
def remesh(self, context):
        lr = self.copiedobject
        hr = self.initialobject

        if self.manifold_method == "print3d":
            isloaded = addon_utils.check("object_print3d_utils")[0]
            if not isloaded:
                addon_utils.enable("object_print3d_utils")
            bpy.ops.mesh.print3d_clean_non_manifold()
            if not isloaded:
                addon_utils.disable("object_print3d_utils")

        elif self.manifold_method == "fill":
            bpy.ops.object.editmode_toggle()
            bpy.ops.mesh.select_mode(type="EDGE")
            bpy.ops.mesh.select_all(action='DESELECT')
            bpy.ops.mesh.select_non_manifold()
            bpy.ops.mesh.fill()
            bpy.ops.object.editmode_toggle()

        elif self.manifold_method == "manifold":
            self.report({"ERROR"}, "Manifold is not implemented yet")
            return {"CANCELLED"}

        elif self.manifold_method == "meshlab":
            self.report({"ERROR"}, "Meshlab manifolding is not implemented yet")
            return {"CANCELLED"}

        return {"FINISHED"} 
Example #17
Source File: importer.py    From cats-blender-plugin with MIT License 4 votes vote down vote up
def execute(self, context):
        global zip_files
        zip_files = {}
        has_zip_file = False

        Common.remove_unused_objects()

        # Make sure that the first layer is visible
        if hasattr(context.scene, 'layers'):
            context.scene.layers[0] = True

        # Save all current objects to check which armatures got added by the importer
        pre_import_objects = [obj for obj in bpy.data.objects if obj.type == 'ARMATURE']

        # Import the files using their corresponding importer
        if self.directory:
            for f in self.files:
                file_name = f.name
                self.import_file(self.directory, file_name)
                if file_name.lower().endswith('.zip'):
                    has_zip_file = True
        # If this operator is called with no directory but a filepath argument, import that
        elif self.filepath:
            print(self.filepath)
            self.import_file(os.path.dirname(self.filepath), os.path.basename(self.filepath))

        if has_zip_file:
            if not zip_files:
                Common.show_error(4, ['The selected zip file contains no importable models.'])

            # Import all models from zip files that contain only one importable model
            remove_keys = []
            for zip_path, files in copy.deepcopy(zip_files).items():
                context.scene.zip_content = zip_path + ' ||| ' + files[0]
                if len(files) == 1:
                    ImportAnyModel.extract_file()
                    remove_keys.append(zip_path)

            # Remove the models from zip file list that got already imported
            for key in remove_keys:
                zip_files.pop(key)

            # Only if a zip contains more than one model, open the zip model selection popup
            if zip_files.keys():
                bpy.ops.cats_importer.zip_popup('INVOKE_DEFAULT')

        # Create list of armatures that got added during import, select them in cats and fix their bone orientations if necessary
        fix_armatures_post_import(pre_import_objects)

        return {'FINISHED'} 
Example #18
Source File: bl_extract_messages.py    From Fluid-Designer with GNU General Public License v3.0 4 votes vote down vote up
def dump_messages(do_messages, do_checks, settings):
    bl_ver = "Blender " + bpy.app.version_string
    bl_hash = bpy.app.build_hash
    bl_date = datetime.datetime.strptime(bpy.app.build_date.decode() + "T" + bpy.app.build_time.decode(),
                                         "%Y-%m-%dT%H:%M:%S")
    pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, bl_ver, bl_hash, bl_date, bl_date.year,
                                                settings=settings)
    msgs = pot.msgs

    # Enable all wanted addons.
    # For now, enable all official addons, before extracting msgids.
    addons = utils.enable_addons(support={"OFFICIAL"})
    # Note this is not needed if we have been started with factory settings, but just in case...
    utils.enable_addons(support={"COMMUNITY", "TESTING"}, disable=True)

    reports = _gen_reports(_gen_check_ctxt(settings) if do_checks else None)

    # Get strings from RNA.
    dump_rna_messages(msgs, reports, settings)

    # Get strings from UI layout definitions text="..." args.
    dump_py_messages(msgs, reports, addons, settings)

    # Get strings from C source code.
    dump_src_messages(msgs, reports, settings)

    # Get strings from addons' categories.
    for uid, label, tip in bpy.types.WindowManager.addon_filter[1]['items'](bpy.context.window_manager, bpy.context):
        process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' categories", reports, None, settings)
        if tip:
            process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Add-ons' categories", reports, None, settings)

    # Get strings specific to translations' menu.
    for lng in settings.LANGUAGES:
        process_msg(msgs, settings.DEFAULT_CONTEXT, lng[1], "Languages’ labels from bl_i18n_utils/settings.py",
                    reports, None, settings)
    for cat in settings.LANGUAGES_CATEGORIES:
        process_msg(msgs, settings.DEFAULT_CONTEXT, cat[1],
                    "Language categories’ labels from bl_i18n_utils/settings.py", reports, None, settings)

    #pot.check()
    pot.unescape()  # Strings gathered in py/C source code may contain escaped chars...
    print_info(reports, pot)
    #pot.check()

    if do_messages:
        print("Writing messages…")
        pot.write('PO', settings.FILE_NAME_POT)

    print("Finished extracting UI messages!")

    return pot  # Not used currently, but may be useful later (and to be consistent with dump_addon_messages!). 
Example #19
Source File: __init__.py    From Blender-For-UnrealEngine-Addons with GNU General Public License v3.0 4 votes vote down vote up
def execute(self, context):
			scene = bpy.context.scene
			
			def CheckIfFbxPluginIsActivated():
				is_enabled, is_loaded = addon_utils.check("io_scene_fbx")
				if is_enabled == True and is_enabled == True:
					return True					
				return False

			
			def GetIfOneTypeCheck():
				if (scene.static_export
				or scene.static_collection_export
				or scene.skeletal_export
				or scene.anin_export
				or scene.alembic_export
				or scene.camera_export):
					return True
				else:
					return False
					

			if CheckIfFbxPluginIsActivated() == False:
				self.report({'WARNING'}, 'Add-on FBX format is not activated! Edit > Preferences > Add-ons > And check "FBX format"')
				return {'FINISHED'}	
			
			if GetIfOneTypeCheck():
				#Primary check	if file is saved to avoid windows PermissionError
				if bpy.data.is_saved:
					scene.UnrealExportedAssetsList.clear()
					start_time = time.perf_counter()
					UpdateNameHierarchy()
					bfu_ExportAsset.ExportForUnrealEngine()
					bfu_WriteText.WriteAllTextFiles()

					if len(scene.UnrealExportedAssetsList) > 0:
						self.report({'INFO'}, "Export of "+str(len(scene.UnrealExportedAssetsList))+
						" asset(s) has been finalized in "+str(time.perf_counter()-start_time)+" sec. Look in console for more info.")
						print("========================= Exported asset(s) =========================")
						print("")
						for line in bfu_WriteText.WriteExportLog().splitlines():
							print(line)
						print("")
						print("========================= ... =========================")
					else:
						self.report({'WARNING'}, "Not found assets with \"Export and child\" properties or collection to export.")
				else:
					self.report({'WARNING'}, "Please save this blend file before export")
			else:
				self.report({'WARNING'}, "No asset type is checked.")
				return {'FINISHED'}
			return {'FINISHED'}


	#Categories :