Python bpy.props 模块,EnumProperty() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用bpy.props.EnumProperty()

项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def register():
    bpy.types.Scene.save_after_render = BoolProperty(
                    name='Save after render',
                    default=True,
                    description='Automatically save rendered images into: //auto_save/')
    bpy.types.Scene.save_blend = BoolProperty(
            name = 'with .blend',
                    default=True,
                    description='Also save .blend file into: //auto_save/') 
    bpy.types.Scene.auto_save_format = EnumProperty(
                    name='Auto Save File Format',
                    description='File Format for the auto saves.',
                    items={
                    ('PNG', 'png', 'Save as png'),
                    ('JPEG', 'jpg', 'Save as jpg'),
                    ('OPEN_EXR_MULTILAYER', 'exr', 'Save as multilayer exr')},
                    default='PNG')
    bpy.types.Scene.auto_save_subfolders = BoolProperty(
                    name='subfolder',
                    default=False,
                    description='Save into individual subfolders per blend name')
    bpy.app.handlers.render_post.append(auto_save_render)
    bpy.types.RENDER_PT_render.append(auto_save_UI)
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def register():
    bpy.utils.register_module(__name__)

    bpy.types.Scene.cloudparticles = BoolProperty(
        name="Particles",
        description="Generate Cloud as Particle System",
        default=False)

    bpy.types.Scene.cloudsmoothing = BoolProperty(
        name="Smoothing",
        description="Smooth Resultant Geometry From Gen Cloud Operation",
        default=True)

    bpy.types.Scene.cloud_type = EnumProperty(
        name="Type",
        description="Select the type of cloud to create with material settings",
        items=[("0", "Stratus", "Generate Stratus_foggy Cloud"),
               ("1", "Cumulous", "Generate Cumulous_puffy Cloud"),
               ("2", "Cirrus", "Generate Cirrus_wispy Cloud"),
               ("3", "Explosion", "Generate Explosion"),
              ],
        default='0')
项目:blender-addons    作者:scorpion81    | 项目源码 | 文件源码
def register():
    bpy.utils.register_module(__name__)

    bpy.types.Scene.cloudparticles = BoolProperty(
        name="Particles",
        description="Generate Cloud as Particle System",
        default=False)

    bpy.types.Scene.cloudsmoothing = BoolProperty(
        name="Smoothing",
        description="Smooth Resultant Geometry From Gen Cloud Operation",
        default=True)

    bpy.types.Scene.cloud_type = EnumProperty(
        name="Type",
        description="Select the type of cloud to create with material settings",
        items=[("0", "Stratus", "Generate Stratus_foggy Cloud"),
               ("1", "Cumulous", "Generate Cumulous_puffy Cloud"),
               ("2", "Cirrus", "Generate Cirrus_wispy Cloud"),
               ("3", "Explosion", "Generate Explosion"),
              ],
        default='0')
项目:assethub    作者:portnov    | 项目源码 | 文件源码
def register():

    WindowManager.assethub_component = EnumProperty(name="Component", items = components_from_assethub)
    WindowManager.assethub_tag = EnumProperty(name="Tag", default=None, items = tags_from_assethub)
    WindowManager.assethub_asset = EnumProperty(name="Asset", items = previews_from_assethub)
    WindowManager.assethub_asset_url = StringProperty(name="Asset URL")

    client.Component.register("blender", "sverchok-sn1", SverchokSn1)
    client.Component.register("blender", "sverchok-layout", SverchokLayout)

    bpy.utils.register_class(ImportOperator)
    bpy.utils.register_class(SettingsPanel)
    bpy.utils.register_class(ImportPanel)
    bpy.utils.register_class(PostScriptPanel)
    bpy.utils.register_class(PostScriptOperator)
    bpy.utils.register_class(BrowseAssetOperator)
    bpy.types.INFO_MT_file_import.append(menu_func)
项目:coa_tools    作者:ndee85    | 项目源码 | 文件源码
def enum_sprite_previews(self, context):
    """EnumProperty callback"""
    enum_items = []
    if context is None:
        return enum_items
    if self.coa_type == "MESH":

        # Get the preview collection (defined in register func).
        coa_pcoll = preview_collections["coa_thumbs"]

        #thumb_dir_path = bpy.utils.user_resource("DATAFILES","coa_thumbs")
        thumb_dir_path = os.path.join(context.user_preferences.filepaths.temporary_directory,"coa_thumbs")

        if os.path.exists(thumb_dir_path):
            # Scan the directory for png files
            image_paths = []
            for fn in os.listdir(thumb_dir_path):
                if fn.lower().endswith(".png") and self.name in fn:
                    image_paths.append(fn)      
            for i, name in enumerate(image_paths):
                if i < self.coa_tiles_x * self.coa_tiles_y:
                    filepath = os.path.join(thumb_dir_path, name)

                    if name in coa_pcoll:
                        thumb = coa_pcoll[name]
                    else:    
                        thumb = coa_pcoll.load(name, filepath, 'IMAGE')
                    enum_items.append((str(i), name, "", thumb.icon_id, i))
    elif self.coa_type == "SLOT":
        for i,slot in enumerate(self.coa_slot):
            if slot.mesh != None:
                img = slot.mesh.materials[0].texture_slots[0].texture.image
                icon = bpy.types.UILayout.icon(img)
                enum_items.append((str(i), slot.mesh.name, "", icon, i))

    return enum_items
项目:CinematicAspectRatios    作者:johnroper100    | 项目源码 | 文件源码
def register():
    bpy.types.Scene.CAR_sizes = EnumProperty(
        items=sizes,
        name="Image Size",
        description="The output image size",
        default="1080p",
        update=CAR_update_resolution)
    bpy.types.Scene.CAR_ratios = EnumProperty(
        items=ratios,
        name="Aspect Ratio",
        description="the output image ratio",
        default="1.77:1",
        update=CAR_update_resolution)
    bpy.types.RENDER_PT_dimensions.append(CAR_panel)
项目:Sverchok    作者:Sverchok    | 项目源码 | 文件源码
def class_factory(func):
    """create a node class based on a function that has been preprocessed
    with get signature or from @stateful"""

    if hasattr(func, "cls_bases"):
        bases = func.cls_bases + (bpy.types.Node,)
    else:
        bases = (NodeBase, bpy.types.Node)

    cls_dict = {}
    cls_name = func.bl_idname
    cls_dict['bl_idname'] = func.bl_idname
    cls_dict['bl_label'] = func.label

    for name, prop in func.properties.items():
        #print(name, prop)
        cls_dict[name] = prop

    if hasattr(func, 'id'):
        func_dict, func_list = NodeDynSignature.get_multi(func)
        default = func_list[0][0]
        cls_dict['mode'] = EnumProperty(items=func_list,
                                        default=default,
                                        update=NodeDynSignature.update_mode)
        cls_dict['bl_label'] = func.multi_label

    for name in {"draw_buttons", "draw_buttons_ext", "update", "draw_label"}:
        attr = getattr(func, name, None)
        if callable(attr):
            cls_dict[name] = attr

    cls = type(cls_name, bases, cls_dict)
    func.cls = cls
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def register():
    from bpy.utils import register_class
    for mod in _modules_loaded:
        for cls in mod.classes:
            register_class(cls)

    # space_userprefs.py
    from bpy.props import StringProperty, EnumProperty
    from bpy.types import WindowManager

    def addon_filter_items(self, context):
        import addon_utils

        items = [('All', "All", "All Add-ons"),
                 ('User', "User", "All Add-ons Installed by User"),
                 ('Enabled', "Enabled", "All Enabled Add-ons"),
                 ('Disabled', "Disabled", "All Disabled Add-ons"),
                 ]

        items_unique = set()

        for mod in addon_utils.modules(refresh=False):
            info = addon_utils.module_bl_info(mod)
            items_unique.add(info["category"])

        items.extend([(cat, cat, "") for cat in sorted(items_unique)])
        return items

    WindowManager.addon_search = StringProperty(
            name="Search",
            description="Search within the selected filter",
            options={'TEXTEDIT_UPDATE'},
            )
    WindowManager.addon_filter = EnumProperty(
            items=addon_filter_items,
            name="Category",
            description="Filter add-ons by category",
            )

    WindowManager.addon_support = EnumProperty(
            items=[('OFFICIAL', "Official", "Officially supported"),
                   ('COMMUNITY', "Community", "Maintained by community developers"),
                   ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)")
                   ],
            name="Support",
            description="Display support level",
            default={'OFFICIAL', 'COMMUNITY'},
            options={'ENUM_FLAG'},
            )
    # done...