Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

May 18, 2015

Register / Unregister many bpy.props

Registering and unregistering many properties

this may be frowned upon, but so is repetition. so whatever.
def properties():
    def get_color_prop():
        WHITE = (1, 1, 1)
        return FloatVectorProperty(default=WHITE, subtype='COLOR', min=0.0, max=1.0)

    props = dict(
        display_indices=IntProperty(
            name="Display indices", default=0),
        display_sel_only=BoolProperty(
            name="Selected only",
            description="Only display indices of selected vertices/edges/faces",
            default=True),
        display_vert_index=BoolProperty(
            name="Vertices",
            description="Display vertex indices",
            default=True),
        display_face_index=BoolProperty(
            name="Faces",
            description="Display face indices"),
        live_mode=BoolProperty(
            name="Live",
            description="Toggle live update of the selection, can be slow",
            default=False),
        vcol_helper_color_1=get_color_prop(),
        vcol_helper_color_2=get_color_prop(),
        vcol_helper_color_3=get_color_prop(),
        vcol_helper_color_4=get_color_prop()
    )
    return props


def register_properties():
    for prop_name, prop_config in properties().items():
        setattr(Scene, prop_name, prop_config)


def unregister_properties():
    for prop_name in properties().keys():
        exec('del Scene.{0}'.format(prop_name))