def register(): preview_images['images'] = previews.new() bpy.utils.register_module(__name__) bpy.types.WindowManager.image_preview = bpy.props.EnumProperty( items=get_enum_previews_from_file, name='Image preview', update=update_image_preview)
def register(): global icons_collection icons = previews.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons.load(name, os.path.join(icons_dir, icon), 'IMAGE') icons_collection["main"] = icons archipack_material.register() archipack_snap.register() archipack_manipulator.register() archipack_reference_point.register() archipack_autoboolean.register() archipack_door.register() archipack_window.register() archipack_stair.register() archipack_wall2.register() archipack_roof.register() archipack_slab.register() archipack_fence.register() archipack_truss.register() archipack_floor.register() archipack_rendering.register() bpy.utils.register_class(Archipack_Pref) bpy.utils.register_class(TOOLS_PT_Archipack_Create) bpy.utils.register_class(ARCHIPACK_MT_create) bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
def register(): global icons_collection icons = previews.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons.load(name, os.path.join(icons_dir, icon), 'IMAGE') icons_collection["main"] = icons archipack_progressbar.register() archipack_material.register() archipack_snap.register() archipack_manipulator.register() archipack_reference_point.register() archipack_autoboolean.register() archipack_door.register() archipack_window.register() archipack_stair.register() archipack_wall2.register() archipack_roof.register() archipack_slab.register() archipack_fence.register() archipack_truss.register() archipack_floor.register() archipack_rendering.register() bpy.utils.register_class(archipack_data) WindowManager.archipack = PointerProperty(type=archipack_data) bpy.utils.register_class(Archipack_Pref) update_panel(None, bpy.context) bpy.utils.register_class(ARCHIPACK_MT_create) bpy.types.INFO_MT_mesh_add.append(menu_func)
def load_icons(): """Loads/reloads icons from the icons directory. This is also used in a callback function in addon preferences, which makes changing icon color possible without reloading the addon. """ # === Remove the current icons and clear preview_collections === for pcoll in _preview_collections.values(): previews.remove(pcoll) _preview_collections.clear() # === Load new icons === pcoll = previews.new() prefs = bpy.context.preferences.addons["modifier_list"].preferences color = prefs.icon_color icons_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "icons", color) icons_dir_files = os.listdir(icons_dir) all_icon_files = [ icon for icon in icons_dir_files if icon.endswith(".png") ] all_icon_names = [icon[0:-4] for icon in all_icon_files] all_icon_files_and_names = zip(all_icon_names, all_icon_files) for icon_name, icon_file in all_icon_files_and_names: pcoll.load(icon_name, os.path.join(icons_dir, icon_file), 'IMAGE') _preview_collections["main"] = pcoll
def register(): """ Register all custom operators, panels, ui-lists and properties. """ from bpy.utils import register_class, previews import bpy import os bookgen_icons = previews.new() bpy.types.Scene.bookgen_icons = bookgen_icons icons_dir = os.path.join(os.path.dirname(__file__), "icons") bookgen_icons.load("shelf", os.path.join(icons_dir, "shelf.png"), 'IMAGE') bookgen_icons.load("stack", os.path.join(icons_dir, "stack.png"), 'IMAGE') bookgen_icons.load("rebuild", os.path.join(icons_dir, "rebuild.png"), 'IMAGE') for cls in classes: register_class(cls) bpy.types.Collection.BookGenGroupingProperties = bpy.props.PointerProperty( type=BookGenGroupingProperties) bpy.types.Scene.BookGenSettings = bpy.props.CollectionProperty( type=BookGenProperties) bpy.types.Scene.BookGenAddonProperties = bpy.props.PointerProperty( type=BookGenAddonProperties) bpy.app.handlers.load_post.append(bookgen_startup)
def register(): #icons global icons_dict icons_dict = iconsLib.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons_dict.load(name, os.path.join(icons_dir, icon), 'IMAGE') #operators nodes_terrain_analysis_reclassify.register() #this module has its own register function because it contains PropertyGroup that must be specifically registered bpy.utils.register_module(__name__) #register all imported operators of the current module #menus bpy.types.INFO_MT_file_import.append(menu_func_import) bpy.types.INFO_MT_file_export.append(menu_func_export) #shortcuts wm = bpy.context.window_manager km = wm.keyconfigs.active.keymaps['3D View'] kmi = km.keymap_items.new(idname='view3d.map_start', value='PRESS', type='NUMPAD_ASTERIX', ctrl=False, alt=False, shift=False, oskey=False) #config core settings prefs = bpy.context.user_preferences.addons[__package__].preferences cfg = getSettings() cfg['proj_engine'] = prefs.projEngine cfg['img_engine'] = prefs.imgEngine setSettings(cfg)
def register_icons(): icons = ["BUILD_ICON", "TWITTER", "YOUTUBE", "GUMROAD"] Scene_Prop.blender_project_manager_icons = previews.new() icons_dir = p.join(p.dirname(p.dirname(__file__)), "icons") for icon in icons: Scene_Prop.blender_project_manager_icons.load( icon, p.join(icons_dir, icon + ".png"), "IMAGE")
def register(): global icons_dict icons_dict = iconsLib.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons_dict.load(name, os.path.join(icons_dir, icon), 'IMAGE') reclassify.register( ) #this module has its own register function because it contains PropertyGroup that must be specifically registered bpy.utils.register_module(__name__) bpy.types.INFO_MT_file_import.append(menu_func_import) bpy.types.INFO_MT_file_export.append(menu_func_export) wm = bpy.context.window_manager km = wm.keyconfigs.active.keymaps['3D View'] kmi = km.keymap_items.new(idname='view3d.map_start', value='PRESS', type='NUMPAD_ASTERIX', ctrl=False, alt=False, shift=False, oskey=False)
def register(): global icons_collection icons = previews.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons.load(name, os.path.join(icons_dir, icon), 'IMAGE') icons_collection["main"] = icons archipack_progressbar.register() archipack_material.register() archipack_snap.register() archipack_manipulator.register() archipack_reference_point.register() archipack_autoboolean.register() archipack_door.register() archipack_window.register() archipack_stair.register() archipack_wall2.register() archipack_roof.register() archipack_slab.register() archipack_fence.register() archipack_truss.register() archipack_floor.register() archipack_rendering.register() bpy.utils.register_class(archipack_data) WindowManager.archipack = PointerProperty(type=archipack_data) bpy.utils.register_class(Archipack_Pref) update_panel(None, bpy.context) bpy.utils.register_class(ARCHIPACK_create_menu) bpy.types.INFO_MT_mesh_add.append(menu_func)
def register(): #icons global icons_dict icons_dict = iconsLib.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons_dict.load(name, os.path.join(icons_dir, icon), 'IMAGE') #operators if TERRAIN_RECLASS: nodes_terrain_analysis_reclassify.register() #this module has its own register function because it contains PropertyGroup that must be specifically registered bpy.utils.register_module(__name__) #register all imported operators of the current module #menus bpy.types.INFO_MT_file_import.append(menu_func_import) bpy.types.INFO_MT_file_export.append(menu_func_export) #shortcuts wm = bpy.context.window_manager kc = wm.keyconfigs.active if kc is not None: #no keyconfig when Blender from commandline with background flag km = kc.keymaps['3D View'] if BASEMAPS: kmi = km.keymap_items.new(idname='view3d.map_start', value='PRESS', type='NUMPAD_ASTERIX', ctrl=False, alt=False, shift=False, oskey=False) #config core settings prefs = bpy.context.user_preferences.addons[__package__].preferences cfg = getSettings() cfg['proj_engine'] = prefs.projEngine cfg['img_engine'] = prefs.imgEngine setSettings(cfg)
def register(): bpy.utils.register_module(__name__) pcoll = previews.new() preview_collections["prev"] = pcoll bpy.types.Scene.prev = EnumProperty(items = env_previews, update = update_hdr) bpy.types.Scene.favs = EnumProperty(name = 'Favorites', items = get_favs_enum, update = update_favs) bpy.types.Scene.dynamic_load = BoolProperty(default = True, description = 'Load the image dynamically.') bpy.types.Scene.dynamic_cleanup = BoolProperty(default = False, description = 'Remove 0 user images dynamically.') bpy.types.Scene.recursive_search = BoolProperty(default = False, update = update_dir, description = 'Enable/Disable Recursive search.') bpy.types.Scene.set_projection = BoolProperty(default = False, update = update_hdr, description = 'Set the projection dynamically.') bpy.types.Scene.display_location = EnumProperty( name = 'Display location', items = (('Tools','Tools',''),('Properties','Properties','')), update = update_display, description = "Where to place the add-on's panel." ) bpy.types.Scene.previews_dir = StringProperty( name="Folder Path", subtype='DIR_PATH', default="", update = update_dir, description = 'Path to the folder containing the images.' ) bpy.types.Scene.sub_dirs = IntProperty( default = 0, min = 0, max = 20, update = update_dir, description = 'Look for HDRIs in the sub folder(s), at this level, 0 = No recursion.' )
def init(): """Initialization function for getting hold of preview collection variable with already created custom icon objects. """ if CUSTOM_ICONS not in _preview_collections: pcoll = previews.new() # load icons tools_paths = _path.get_addon_installation_paths() if len(tools_paths) > 0: for icon_type in _ICON_consts.Types.as_list(): # create path to current icon "ui/icons/icon_type" icon_path = os.path.join( tools_paths[0], 'ui' + os.sep + 'icons' + os.sep + icon_type) if os.path.isfile(icon_path): if icon_type not in pcoll: pcoll.load(icon_type, icon_path, 'IMAGE') else: lprint( "W Icon %r is missing. Please try to install addon again!", (icon_type, )) _preview_collections[CUSTOM_ICONS] = pcoll
def load_icons(): # Path to the icons folder # The path is calculated relative to this py file inside the addon folder main_dir = pathlib.Path(os.path.dirname(__file__)).parent.resolve() resources_dir = os.path.join(str(main_dir), "resources") icons_dir = os.path.join(resources_dir, "icons") pcoll = previews.new() # Load a preview thumbnail of a file and store in the previews collection pcoll.load('FACE', os.path.join(icons_dir, 'icon-row-face-32.png'), 'IMAGE') pcoll.load('SUIT', os.path.join(icons_dir, 'icon-row-suit-32.png'), 'IMAGE') pcoll.load('VP', os.path.join(icons_dir, 'icon-vp-32.png'), 'IMAGE') pcoll.load('PAIRED', os.path.join(icons_dir, 'icon-paired-32.png'), 'IMAGE') pcoll.load('ROKOKO', os.path.join(icons_dir, 'icon-rokoko-32.png'), 'IMAGE') pcoll.load('RECORD', os.path.join(icons_dir, 'icon-record-32.png'), 'IMAGE') pcoll.load('RESTART', os.path.join(icons_dir, 'icon-restart-32.png'), 'IMAGE') pcoll.load('STOP', os.path.join(icons_dir, 'icon-stop-white-32.png'), 'IMAGE') pcoll.load('CALIBRATE', os.path.join(icons_dir, 'icon-straight-pose-32.png'), 'IMAGE') pcoll.load('STUDIO_LIVE_LOGO', os.path.join(icons_dir, 'icon-studio-live-32.png'), 'IMAGE') global icons icons = pcoll
def register_infofonts(default=None): global infofonts infofonts = previews.new() fontspath = os.path.join(get_path(), "assets", 'Create', 'infofonts') fontfiles = [ f for f in os.listdir(fontspath) if f.endswith(".ttf") or f.endswith(".TTF") ] items = [] for font in sorted(fontfiles): fontpath = os.path.join(fontspath, font) fontname = font preview = infofonts.load(fontname, fontpath, 'FONT') items.append( (fontname, fontname, "", preview.icon_id, preview.icon_id)) enum = EnumProperty(items=items, default=default) setattr(bpy.types.WindowManager, "infofonts", enum)
def register(): global icons_collection icons = previews.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons.load(name, os.path.join(icons_dir, icon), 'IMAGE') icons_collection["main"] = icons archipack_material.register() archipack_snap.register() archipack_manipulator.register() archipack_reference_point.register() archipack_autoboolean.register() archipack_door.register() archipack_window.register() archipack_stair.register() archipack_wall2.register() archipack_roof.register() archipack_slab.register() archipack_fence.register() archipack_truss.register() archipack_floor.register() archipack_rendering.register() bpy.utils.register_class(Archipack_Pref) bpy.utils.register_class(TOOLS_PT_Archipack_Create) bpy.utils.register_class(ARCHIPACK_MT_create) bpy.types.VIEW3D_MT_mesh_add.append(menu_func)
def add(self, category): """ Add a category """ if category not in self: self._enums[category] = [] self._folders[category] = {} self[category] = previews.new()
def register_icons(): preview_coll = previews.new() icons_folder = join(dirname(__file__), "custom_icons") for icon in ICONS: preview_coll.load(icon, join(icons_folder, icon + ".png"), 'IMAGE') ICON_COLLECTION["main"] = preview_coll
def icons(): preview = previews.new() for file in os.listdir(addon.path.icons()): if file.endswith('.png'): preview.load(file[:-4], os.path.join(addon.path.icons(), file), 'IMAGE') addon.icons['main'] = preview
def load_icons(): print("[ATELIER SCULPT] Loading Icons...") icons = glob.glob(join(dirname(__file__), "*_icon.png")) pcoll = previews.new() for img in icons: #print(img) if isfile(img): pcoll.load(basename(img)[:-4], img, 'IMAGE') preview_collections["main"] = pcoll
def register_lockedlib(): global locked locked = previews.new() lockedpath = os.path.join(get_path(), "resources", 'locked.png') preview = locked.load("LOCKED", lockedpath, 'IMAGE') items = [("LOCKED", "LOCKED", "LIBRARY is LOCKED", preview.icon_id, preview.icon_id)] enum = EnumProperty(items=items) setattr(bpy.types.WindowManager, "lockeddecallib", enum)
def register_icons(): path = os.path.join(get_prefs().path, "icons") icons = previews.new() for i in sorted(os.listdir(path)): if i.endswith(".png"): iconname = i[:-4] filepath = os.path.join(path, i) icons.load(iconname, filepath, 'IMAGE') return icons
def register(): global icons_collection icons = previews.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons.load(name, os.path.join(icons_dir, icon), 'IMAGE') icons_collection["main"] = icons archipack_progressbar.register() archipack_material.register() archipack_snap.register() archipack_manipulator.register() archipack_curveman.register() archipack_dimension.register() archipack_reference_point.register() archipack_autoboolean.register() archipack_door.register() archipack_window.register() archipack_stair.register() archipack_wall.register() archipack_wall2.register() archipack_roof.register() archipack_slab.register() archipack_fence.register() archipack_truss.register() archipack_blind.register() archipack_kitchen.register() archipack_molding.register() archipack_custom.register() # archipack_toolkit.register() archipack_floor.register() archipack_floor_heating.register() archipack_rendering.register() archipack_section.register() archipack_animation.register() archipack_io.register() archipack_2d_layout.register() archipack_io_export_svg.register() archipack_polylines.register() bpy.utils.register_class(archipack_data) WindowManager.archipack = PointerProperty(type=archipack_data) bpy.utils.register_class(Archipack_Pref) update_panel(None, bpy.context) bpy.utils.register_class(ARCHIPACK_MT_create_menu) bpy.types.INFO_MT_mesh_add.append(menu_func) addon_updater_ops.register(bl_info)
def __init__(self): self.is_valid = False # Is library loaded succesfully? self.path = "" # library root directory path self.categories = {} self.materials = {} self.previews = previews.new() self.material_preview_cache = {} # info for currently selected category self.active_category = "" # current self.active_materials = {} self.is_valid = self.load_manifest()
def register_instant_decals(default=None, reloading=False): global instantdecals instantpath = os.path.join(get_path(), "assets", 'Create', 'instant') items = [] instantdecals = previews.new() # also collect uuids you encouter and the decalnames and libraries they are found in. uuids = {} if not reloading else bpy.types.WindowManager.instantdecaluuids folders = sorted([(f, os.path.join(instantpath, f)) for f in os.listdir(instantpath) if os.path.isdir(os.path.join(instantpath, f))], key=lambda x: x[0], reverse=False) for decalname, decalpath in folders: files = os.listdir(decalpath) if all([f in files for f in ["decal.blend", "decal.png", "uuid"]]): iconpath = os.path.join(decalpath, "decal.png") preview = instantdecals.load(decalname, iconpath, 'IMAGE') items.append( (decalname, decalname, "%s %s" % ("INSTANT", decalname), preview.icon_id, preview.icon_id)) with open(os.path.join(decalpath, "uuid"), "r") as f: uuid = f.read().replace("\n", "") if uuid not in uuids: uuids[uuid] = [] uuids[uuid].append(decalname) enum = EnumProperty(items=items, update=insert_or_remove_decal(instant=True), default=default) setattr(bpy.types.WindowManager, "instantdecallib", enum) # store the uuids setattr(bpy.types.WindowManager, "instantdecaluuids", uuids)
def register(): global icons_dict icons_dict = iconsLib.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons_dict.load(name, os.path.join(icons_dir, icon), 'IMAGE') reclassify.register() #this module has its own register function because it contains PropertyGroup that must be specifically registered bpy.utils.register_module(__name__) bpy.types.INFO_MT_file_import.append(menu_func_import) bpy.types.INFO_MT_file_export.append(menu_func_export) wm = bpy.context.window_manager km = wm.keyconfigs.active.keymaps['3D View'] kmi = km.keymap_items.new(idname='view3d.map_start', value='PRESS', type='NUMPAD_ASTERIX', ctrl=False, alt=False, shift=False, oskey=False)
def add_folder(master): for folder in [ file for file in os.listdir(master.location) if os.path.isdir(os.path.join(master.location, file)) ]: if regex.clean_name(folder, use_re=preference.clean_names) not in [ category.name for category in option.kpack.categories ]: category = option.kpack.categories.add() category.name = regex.clean_name(folder, use_re=preference.clean_names) category.icon = 'FILE_FOLDER' category.folder = folder if folder in insert.thumbnails: previews.remove(insert.thumbnails[folder]) thumbnails = previews.new() thumbnails.location = os.path.join(master.location, folder) thumbnails.images = [] insert.thumbnails[folder] = thumbnails add_blend(master.location, folder, category) if not len(category.blends): option.kpack.categories.remove([ category.name for category in option.kpack.categories ].index(category.name)) else: category = option.kpack.categories[regex.clean_name( folder, use_re=preference.clean_names)] add_blend(master.location, folder, category) images = insert.thumbnails[folder].images enum_items = [] for index, image in enumerate(images): enum_items.append((images[index][0], images[index][0][:14], images[index][0], images[index][1], index)) insert.thumbnails[folder].images = enum_items
def register(): bpy.utils.register_module(__name__) pcoll = previews.new() preview_collections["prev"] = pcoll bpy.types.Scene.prev = EnumProperty(items = env_previews, update = update_hdr) bpy.types.Scene.favs = EnumProperty(name = 'Favorites', items = get_favs_enum, update = update_favs) bpy.types.Scene.display_location = EnumProperty( name = 'Display location', items = (('Tools','Tools',''),('Properties','Properties','')), update = update_display, description = "Where to place the add-on's panel." ) bpy.types.Scene.dynamic_load = BoolProperty(default = True, description = 'Load the image dynamically.') bpy.types.Scene.dynamic_cleanup = BoolProperty(default = False, description = 'Remove 0 user images dynamically.') bpy.types.Scene.previews_dir = StringProperty( name="Folder Path", subtype='DIR_PATH', default="", update = update_dir, description = 'Path to the folder containing the images.' )
def init(): """Initialization function for getting hold of preview collection variable with already created custom icon objects. """ # create new preview only once. # NOTE: We removed previews cleanup from code # because it was crashing Blender when rapidly enabling/disabling BT addon. # So instead of always creating new preview collection we rather reuse existing and # only load icons again with force reload flag, to ensure icons are always reloaded when init is called. if CUSTOM_ICONS not in _preview_collections: pcoll = previews.new() _preview_collections[CUSTOM_ICONS] = pcoll else: pcoll = _preview_collections[CUSTOM_ICONS] print( "INFO\t - Icon collection is already in python memory, re-using it!" ) # load icons tools_paths = _path.get_addon_installation_paths() if len(tools_paths) > 0: for icon_type in _ICON_consts.Types.as_list(): # create path to current icon "ui/icons/icon_type" icon_path = os.path.join( tools_paths[0], 'ui' + os.sep + 'icons' + os.sep + icon_type) if os.path.isfile(icon_path): if icon_type not in pcoll: pcoll.load(icon_type, icon_path, 'IMAGE', force_reload=True) else: lprint( "W Icon %r is missing. Please try to install addon again!", (icon_type, ))
def load_icons(): global preview_collections pcoll = previews.new() prefs = bpy.context.preferences.addons["modifier_list"].preferences color = prefs.icon_color icons_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "icons", color) icons_dir_files = os.listdir(icons_dir) all_icon_files = [ icon for icon in icons_dir_files if icon.endswith(".png") ] all_icon_names = [icon[0:-4] for icon in all_icon_files] all_icon_files_and_names = zip(all_icon_names, all_icon_files) for icon_name, icon_file in all_icon_files_and_names: pcoll.load(icon_name, os.path.join(icons_dir, icon_file), 'IMAGE') preview_collections["main"] = pcoll
def register(): from bpy.utils import register_class for cls in classes: register_class(cls) pcoll = previews.new() preview_collections["prev"] = pcoll bpy.types.Scene.prev = EnumProperty(items=env_previews, update=update_hdr) bpy.types.Scene.favs = EnumProperty( name='Favorites', items=get_favs_enum, update=update_favs, description='List of the favorit folders') bpy.types.Scene.dynamic_load = BoolProperty( default=True, description='Load the images dynamically') bpy.types.Scene.dynamic_cleanup = BoolProperty( default=False, description='Remove 0 user images dynamically') bpy.types.Scene.recursive_search = BoolProperty( default=False, update=update_dir, description='Enable/Disable Recursive search') bpy.types.Scene.set_projection = BoolProperty( default=False, update=update_hdr, description='Set the projection dynamically') bpy.types.Scene.previews_dir = StringProperty( name="Folder Path", subtype='DIR_PATH', default="", update=update_dir, description='Path to the folder containing the images') bpy.types.Scene.sub_dirs = IntProperty( default=0, min=0, max=20, update=update_dir, description= 'Look for HDRIs in the sub folder(s), at this level, 0 = No recursion')
def init(): """Initialization function for getting hold of preview collection variable with already created custom icon objects. """ if CUSTOM_ICONS not in _preview_collections: pcoll = previews.new() # load icons tools_paths = _path.get_addon_installation_paths() if len(tools_paths) > 0: for icon_type in _ICON_consts.Types.as_list(): # create path to current icon "ui/icons/icon_type" icon_path = os.path.join(tools_paths[0], 'ui' + os.sep + 'icons' + os.sep + icon_type) if os.path.isfile(icon_path): if icon_type not in pcoll: pcoll.load(icon_type, icon_path, 'IMAGE') else: lprint("W Icon %r is missing. Please try to install addon again!", (icon_type,)) _preview_collections[CUSTOM_ICONS] = pcoll
def load_icon(): import os try: # if anything goes wrong, for example because we are not running 2.75+ we just ignore it from bpy.utils import previews pcoll = previews.new() # path to the folder where the icon is # the path is calculated relative to this py file inside the addon folder my_icons_dir = os.path.join(os.path.dirname(__file__), "icons") # load all previews icons = [ entry for entry in os.scandir(my_icons_dir) if entry.is_file() and entry.name.endswith('.png') ] for icon in icons: name = os.path.splitext(icon.name)[0] pcoll.load(name, icon.path, 'IMAGE') preview_collections['operator_icons'] = pcoll except Exception as e: print(e) pass
def register_infotextures(default=None): global infotextures infotextures = previews.new() infopath = os.path.join(get_path(), "assets", 'Create', 'infotextures') images = [ f for f in os.listdir(infopath) if f.endswith(".png") or f.endswith(".jpg") ] items = [] for img in sorted(images): imgpath = os.path.join(infopath, img) imgname = img preview = infotextures.load(imgname, imgpath, 'IMAGE') items.append((imgname, imgname, "", preview.icon_id, preview.icon_id)) enum = EnumProperty(items=items, default=default) setattr(bpy.types.WindowManager, "infotextures", enum)
from bpy.utils import previews from os import path from .. import var preview_collections = {} pcoll = previews.new() load = pcoll.load icon_path = path.join load('CUT-ROUND', icon_path(var.icons_path, 'cut-round.png'), 'IMAGE') load('CUT-OVAL', icon_path(var.icons_path, 'cut-oval.png'), 'IMAGE') load('CUT-EMERALD', icon_path(var.icons_path, 'cut-emerald.png'), 'IMAGE') load('CUT-MARQUISE', icon_path(var.icons_path, 'cut-marquise.png'), 'IMAGE') load('CUT-PEAR', icon_path(var.icons_path, 'cut-pear.png'), 'IMAGE') load('CUT-BAGUETTE', icon_path(var.icons_path, 'cut-baguette.png'), 'IMAGE') load('CUT-SQUARE', icon_path(var.icons_path, 'cut-square.png'), 'IMAGE') load('CUT-ASSCHER', icon_path(var.icons_path, 'cut-asscher.png'), 'IMAGE') load('CUT-CUSHION', icon_path(var.icons_path, 'cut-cushion.png'), 'IMAGE') load('CUT-PRINCESS', icon_path(var.icons_path, 'cut-princess.png'), 'IMAGE') load('CUT-TRILLION', icon_path(var.icons_path, 'cut-trillion.png'), 'IMAGE') load('CUT-OCTAGON', icon_path(var.icons_path, 'cut-octagon.png'), 'IMAGE') load('CUT-HEART', icon_path(var.icons_path, 'cut-heart.png'), 'IMAGE') load('CUT-RADIANT', icon_path(var.icons_path, 'cut-radiant.png'), 'IMAGE') load('CUT-FLANDERS', icon_path(var.icons_path, 'cut-flanders.png'), 'IMAGE') load('CUT-TRILLIANT', icon_path(var.icons_path, 'cut-trilliant.png'), 'IMAGE') load('CUT-TRIANGLE', icon_path(var.icons_path, 'cut-triangle.png'), 'IMAGE') load('TOOL-CUT', icon_path(var.icons_path, 'tool-cut.png'), 'IMAGE') load('TOOL-SINGLE_PRONG', icon_path(var.icons_path, 'tool-single_prong.png'), 'IMAGE') load('TOOL-CUTTER', icon_path(var.icons_path, 'tool-cutter.png'), 'IMAGE')
def create(): global icons icons = previews.new()
from bpy.utils import previews from os import scandir from os.path import splitext from .. import var preview_collections = {} icon_previews = previews.new() load = icon_previews.load for entry in scandir(var.icons_path): load(splitext(entry.name)[0].upper(), entry.path, 'IMAGE') preview_collections['icons'] = icon_previews
def register(): #icons global icons_dict icons_dict = iconsLib.new() icons_dir = os.path.join(os.path.dirname(__file__), "icons") for icon in os.listdir(icons_dir): name, ext = os.path.splitext(icon) icons_dict.load(name, os.path.join(icons_dir, icon), 'IMAGE') #operators prefs.register() geoscene.register() for menu in menus: try: bpy.utils.register_class(menu) except ValueError as e: logger.warning( '{} is already registered, now unregister and retry... '. format(menu)) bpy.utils.unregister_class(menu) bpy.utils.register_class(menu) bpy.utils.register_class(BGIS_OT_logs) if BASEMAPS: view3d_mapviewer.register() if IMPORT_GEORASTER: io_import_georaster.register() if IMPORT_SHP: io_import_shp.register() if EXPORT_SHP: io_export_shp.register() if IMPORT_OSM: io_import_osm.register() if IMPORT_ASC: io_import_asc.register() if DELAUNAY: mesh_delaunay_voronoi.register() if DROP: object_drop.register() if GET_DEM: io_get_dem.register() if CAM_GEOPHOTO: add_camera_exif.register() if CAM_GEOREF: add_camera_georef.register() if TERRAIN_NODES: nodes_terrain_analysis_builder.register() if TERRAIN_RECLASS: nodes_terrain_analysis_reclassify.register() if EARTH_SPHERE: mesh_earth_sphere.register() #menus bpy.types.VIEW3D_MT_editor_menus.append(add_gis_menu) #shortcuts if not bpy.app.background: #no ui when running as background wm = bpy.context.window_manager kc = wm.keyconfigs.active if '3D View' in kc.keymaps: km = kc.keymaps['3D View'] if BASEMAPS: kmi = km.keymap_items.new(idname='view3d.map_start', type='NUMPAD_ASTERIX', value='PRESS') #Setup prefs preferences = bpy.context.preferences.addons[__package__].preferences logger.setLevel(logging.getLevelName( preferences.logLevel)) #will affect all child logger #update core settings according to addon prefs settings.proj_engine = preferences.projEngine settings.img_engine = preferences.imgEngine
'cut-marquise', 'cut-pear', 'cut-baguette', 'cut-square', 'cut-asscher', 'cut-cushion', 'cut-princess', 'cut-trillion', 'cut-octagon', 'cut-heart', 'cut-radiant', 'cut-flanders', 'cut-trilliant', 'cut-triangle', 'tool-cut', 'tool-single_prong', 'tool-cutter', 'tool-cutter_seat', 'tool-imitation_3_prong', ) icons = previews.new() load = icons.load for name in icon_names: load(name.upper(), path.join(var.icons_path, name + '.png'), 'IMAGE') preview_collections['icons'] = icons