Exemple #1
0
def set_theme(context, m):
    history_append(text=m, remove_duplicates=True)
    add_scrollback('From the following list pick an index and type "theme_<idx>"', 'INFO')

    import os
    fullpath = bpy.app.binary_path
    directory = os.path.dirname(fullpath)
    num = str(bpy.app.version[0]) + '.' + str(bpy.app.version[1])
    fullext_path = (num + "/scripts/presets/interface_theme").split("/")
    seekable_path = os.path.join(directory, *fullext_path)

    def path_iterator(path_name, kind):
        for fp in os.listdir(path_name):
            if fp.endswith("." + kind):
                yield fp

    themes = list(path_iterator(seekable_path, 'xml'))
    if m.split('_')[1] == 'list':
        print(themes)
        for idx, line in enumerate(themes):
            add_scrollback('[{0}] - '.format(idx) + line[:-4], 'OUTPUT')
    elif m.split('_')[1].strip().isnumeric():
        idx = int(m.split('_')[1].strip())
        fullest_path = os.path.join(seekable_path, themes[idx])
        bpy.ops.script.execute_preset('INVOKE_DEFAULT', filepath=fullest_path, menu_idname="USERPREF_MT_interface_theme_presets")
def print_most_useful():
    content = '''\

for full verbose descriptor use -man

command    |  description
-----------+----------------
tt | tb    |  turntable / trackball nav.
cen        |  centers 3d cursor
cenv       |  centers 3d cursor, aligns views to it
cento      |  centers to selected
endswith!  |  copy current console line if ends with exclm.
x?bpy      |  search blender python for x
x?bs       |  search blenderscripting.blogspot for x
x?py       |  search python docs for x
x?se       |  search B3D StackExchange
x??se      |  regular StackExchange search
vtx, xl    |  enable or trigger tinyCAD vtx (will download)
ico        |  enables icon addon in texteditor panel (Dev)
123        |  use 1 2 3 to select vert, edge, face
-img2p     |  enabled image to plane import addon
-or2s      |  origin to selected.
-dist      |  gives local distance between two selected verts
-gist -o x |  uploads all open text views as x to anon gist.
-debug     |  dl + enable extended mesh index visualiser. it's awesome.
--sort     |  sorting operator: sorts open edgeloop, by index handy for polyline export
-----------+----------------------------------------------------------
-idxv      |  enable by shortcut name (user defined)
enable <named addon>  |  package name or folder name
v2rdim     |  sets render dimensions to current strip.
fc         |  fcurrent -> end.frame
gif <dir>  |  make animated gif of content of dir
'''

    add_scrollback(content, 'OUTPUT')
Exemple #3
0
def in_bpm_commands(context, m):
    if m.startswith("bpm "):
        if m.startswith('bpm pydict '):

            if not current_pydict:
                gist_id = 'ba45d7e0ebea646ce0b5'
                dict_str = get_gist_as_string(gist_id)
                current_pydict.update(ast.literal_eval(dict_str))
            else:
                add_scrollback('Using local copy from earlier..', 'INFO')

            if not current_pydict:
                add_scrollback('failed to access remote listing', 'ERROR')
                add_scrollback('No local copy was found either..', 'ERROR')
                return True

            # to debug..example
            if m == 'bpm pydict cat Mesh':
                g = current_pydict['categories']['Mesh']
                for addon, info in g.items():
                    msg = '{0}: {1}'.format(addon, info['rev'])
                    add_scrollback(msg, 'OUTPUT')

        add_scrollback(m, 'INFO')
    else:
        return False

    return True
def print_most_useful():
    content = '''\

for full verbose descriptor use -man

command    |  description
-----------+----------------
tt | tb    |  turntable / trackball nav.
cen        |  centers 3d cursor
cenv       |  centers 3d cursor, aligns views to it
cento      |  centers to selected
endswith!  |  copy current console line if ends with exclm.
x?bpy      |  search blender python for x
x?bs       |  search blenderscripting.blogspot for x
x?py       |  search python docs for x
x?se       |  search B3D StackExchange
x??se      |  regular StackExchange search
vtx, xl    |  enable or trigger tinyCAD vtx (will download)
ico        |  enables icon addon in texteditor panel (Dev)
123        |  use 1 2 3 to select vert, edge, face
-img2p     |  enabled image to plane import addon
-or2s      |  origin to selected.
-dist      |  gives local distance between two selected verts
-gist -o x |  uploads all open text views as x to anon gist.
-debug     |  dl + enable extended mesh index visualiser. it's awesome.
--sort     |  sorting operator: sorts open edgeloop, by index handy for polyline export
-----------+----------------------------------------------------------
-idxv      |  enable by shortcut name (user defined)
enable <named addon>  |  package name or folder name
v2rdim     |  sets render dimensions to current strip.
fc         |  fcurrent -> end.frame
gif <dir>  |  make animated gif of content of dir
'''

    add_scrollback(content, 'OUTPUT')
def set_theme(context, m):
    history_append(text=m, remove_duplicates=True)
    add_scrollback('From the following list pick an index and type "theme_<idx>"', 'INFO')

    import os
    fullpath = bpy.app.binary_path
    directory = os.path.dirname(fullpath)
    num = str(bpy.app.version[0]) + '.' + str(bpy.app.version[1])
    fullext_path = (num + "/scripts/presets/interface_theme").split("/")
    seekable_path = os.path.join(directory, *fullext_path)

    def path_iterator(path_name, kind):
        for fp in os.listdir(path_name):
            if fp.endswith("." + kind):
                yield fp

    themes = list(path_iterator(seekable_path, 'xml'))
    if m.split('_')[1] == 'list':
        print(themes)
        for idx, line in enumerate(themes):
            add_scrollback('[{0}] - '.format(idx) + line[:-4], 'OUTPUT')
    elif m.split('_')[1].strip().isnumeric():
        idx = int(m.split('_')[1].strip())
        fullest_path = os.path.join(seekable_path, themes[idx])
        bpy.ops.script.execute_preset('INVOKE_DEFAULT', filepath=fullest_path, menu_idname="USERPREF_MT_interface_theme_presets")
    elif m.strip() == 'theme_flatty_light':
        fullest_path = os.path.join(seekable_path, "flatty_light.xml")
        bpy.ops.script.execute_preset('INVOKE_DEFAULT', filepath=fullest_path, menu_idname="USERPREF_MT_interface_theme_presets")        
def make_optimized_animated_gif(m):

    try:
        temp_root = os.path.dirname(__file__)
        fp = os.path.join(temp_root, 'tmp', 'gifbatch.sh')
        print(fp)
        f2 = 'bash {0} {1}'.format(fp, m)
        print(f2)
        subprocess.Popen(f2.split())
    except:
        add_scrollback('failed.. - with errors', 'ERROR')
def run_operator_register(a, b):
    base = os.path.dirname(__file__)
    path_to_file = os.path.join(base, a, b)

    text = bpy.data.texts.load(path_to_file)
    ctx = bpy.context.copy()
    ctx['edit_text'] = text
    bpy.ops.text.run_script(ctx)

    msg = 'added ' + b
    add_scrollback(msg, 'INFO')
Exemple #8
0
def run_operator_register(a, b):
    base = os.path.dirname(__file__)
    path_to_file = os.path.join(base, a, b)

    text = bpy.data.texts.load(path_to_file)
    ctx = bpy.context.copy()
    ctx['edit_text'] = text
    bpy.ops.text.run_script(ctx)

    msg = 'added ' + b
    add_scrollback(msg, 'INFO')
def make_animated_gif(m):
    if not os.path.exists(m):
        add_scrollback('{0} does not exist'.format(m), 'ERROR')

    initial_location = os.getcwd()
    try:
        os.chdir(m)
        f = "convert -delay 10 -loop 0 *png animated.gif"
        subprocess.Popen(f.split())
    except:
        add_scrollback('failed.. - with errors', 'ERROR')

    os.chdir(initial_location)
def make_animated_gif(m):
    if not os.path.exists(m):
        add_scrollback('{0} does not exist'.format(m), 'ERROR')

    initial_location = os.getcwd()
    try:
        os.chdir(m)
        f = "convert -delay 20 -loop 0 *png animated.gif"
        subprocess.Popen(f.split())
    except:
        add_scrollback('failed.. - with errors', 'ERROR')

    os.chdir(initial_location)
def do_console_rewriter(ctx, m):
    fail = 'null ops, check spelling or be less specific'
    msg = fail
    if (m == 'obj='):
        msg = 'obj = bpy.context.active_object'
    elif (m == 'obj=['):
        msg = 'obj = bpy.data.objects[\''
    elif (len(m) > 5) and (m[5:] in bpy.data.objects):
        msg = "obj = bpy.data.objects['{0}']".format(m[5:])

    add_scrollback(m + ' --> ' + msg, 'OUTPUT')
    history_append(text=m, remove_duplicates=True)
    if not (msg == fail):
        ctx.space_data.history[-1].body = msg
Exemple #12
0
def do_console_rewriter(ctx, m):
    fail = 'null ops, check spelling or be less specific'
    msg = fail
    if (m == 'obj='):
        msg = 'obj = bpy.context.active_object'
    elif (m == 'obj=['):
        msg = 'obj = bpy.data.objects[\''
    elif (len(m) > 5) and (m[5:] in bpy.data.objects):
        msg = "obj = bpy.data.objects['{0}']".format(m[5:])

    add_scrollback(m + ' --> ' + msg, 'OUTPUT')
    history_append(text=m, remove_duplicates=True)
    if not (msg == fail):
        ctx.space_data.history[-1].body = msg
def get_sv():
    add_scrollback('getting sverchok bootstrapper', 'OUTPUT')
    string_load = get_gist_as_string("5a4440e7455940174ab9")
    print(string_load[:100])

    svbl = bpy.data.texts.new('sverchok bootloader')
    svbl.write(string_load)
    add_scrollback('execuion bootstrapper complete', 'OUTPUT')

    # until a tidier solution comes along
    ctx = bpy.context.copy()
    ctx['edit_text'] = svbl  # specify the text datablock to execute
    # ctx['area'] = area # not actually needed...
    # ctx['region'] = area.regions[-1] # ... just be nice
    bpy.ops.text.run_script(ctx)
def get_sv():
    add_scrollback('getting sverchok bootstrapper', 'OUTPUT')
    string_load = get_gist_as_string("5a4440e7455940174ab9")
    print(string_load[:100])
    
    svbl = bpy.data.texts.new('sverchok bootloader')
    svbl.write(string_load)
    add_scrollback('execuion bootstrapper complete', 'OUTPUT')

    # until a tidier solution comes along
    ctx = bpy.context.copy()
    ctx['edit_text'] = svbl # specify the text datablock to execute
    # ctx['area'] = area # not actually needed...
    # ctx['region'] = area.regions[-1] # ... just be nice
    bpy.ops.text.run_script(ctx)

    
Exemple #15
0
def view_types_to_console():
    content = """\
bl_<prop>      | allowed
---------------+-------------------------------------------------------------
bl_space_type  | 'CLIP_EDITOR', 'CONSOLE', 'DOPESHEET_EDITOR', 'EMPTY',
               | 'FILE_BROWSER', 'GRAPH_EDITOR', 'IMAGE_EDITOR', 'INFO',
               | 'LOGIC_EDITOR', 'NLA_EDITOR', 'NODE_EDITOR', 'OUTLINER',
               | 'PROPERTIES', 'SEQUENCE_EDITOR', 'TEXT_EDITOR', 'TIMELINE',
               | 'USER_PREFERENCES', 'VIEW_3D'
---------------+-------------------------------------------------------------
bl_region_type | 'CHANNELS', 'HEADER', 'PREVIEW', 'TEMPORARY', 'TOOLS',
               | 'TOOL_PROPS', 'UI', 'WINDOW'
---------------+-------------------------------------------------------------
bl_context     | 'armature_edit', 'curve_edit', 'imagepaint', 'lattice_edit',
               | 'mball_edit', 'mesh_edit', 'objectmode', 'particlemode',
               | 'posemode', 'sculpt_mode', 'surface_edit', 'text_edit',
               | 'vertexpaint', 'weightpaint'
"""
    add_scrollback(content, 'OUTPUT')
Exemple #16
0
def view_types_to_console():
    content = """\
bl_<prop>      | allowed
---------------+-------------------------------------------------------------
bl_space_type  | 'CLIP_EDITOR', 'CONSOLE', 'DOPESHEET_EDITOR', 'EMPTY',
               | 'FILE_BROWSER', 'GRAPH_EDITOR', 'IMAGE_EDITOR', 'INFO',
               | 'LOGIC_EDITOR', 'NLA_EDITOR', 'NODE_EDITOR', 'OUTLINER',
               | 'PROPERTIES', 'SEQUENCE_EDITOR', 'TEXT_EDITOR', 'TIMELINE',
               | 'USER_PREFERENCES', 'VIEW_3D'
---------------+-------------------------------------------------------------
bl_region_type | 'CHANNELS', 'HEADER', 'PREVIEW', 'TEMPORARY', 'TOOLS',
               | 'TOOL_PROPS', 'UI', 'WINDOW'
---------------+-------------------------------------------------------------
bl_context     | 'armature_edit', 'curve_edit', 'imagepaint', 'lattice_edit',
               | 'mball_edit', 'mesh_edit', 'objectmode', 'particlemode',
               | 'posemode', 'sculpt_mode', 'surface_edit', 'text_edit',
               | 'vertexpaint', 'weightpaint'
"""
    add_scrollback(content, 'OUTPUT')
def do_console_rewriter(ctx, m):
    fail = 'null ops, check spelling or be less specific'
    msg = fail
    if (m == 'obj='):
        msg = 'obj = bpy.context.active_object'
    elif (m == 'obj=['):
        msg = 'obj = bpy.data.objects[\''
    elif (len(m) > 5) and (m[5:] in bpy.data.objects):
        msg = "obj = bpy.data.objects['{0}']".format(m[5:])
    elif (m == 'n='):
        msg = 'nodes = bpy.data.node_groups[\'NodeTree\'].nodes'
    elif m.startswith('-fem'):
        msg = 'bm = bmesh.from_edit_mesh(C.object.data)'
    elif (m == 'n=['):
        msg = "ng = bpy.data.node_groups[\'"

    add_scrollback(m + ' --> ' + msg, 'OUTPUT')
    history_append(text=m, remove_duplicates=True)
    if not (msg == fail):
        ctx.space_data.history[-1].body = msg
Exemple #18
0
def do_console_rewriter(ctx, m):
    fail = 'null ops, check spelling or be less specific'
    msg = fail
    if (m == 'obj='):
        msg = 'obj = bpy.context.active_object'
    elif (m == 'obj=['):
        msg = 'obj = bpy.data.objects[\''
    elif (len(m) > 5) and (m[5:] in bpy.data.objects):
        msg = "obj = bpy.data.objects['{0}']".format(m[5:])
    elif (m == 'n='):
        msg = 'nodes = bpy.data.node_groups[\'NodeTree\'].nodes'
    elif m.startswith('-fem'):
        msg = 'bm = bmesh.from_edit_mesh(C.object.data)'
    elif (m == 'n=['):
        msg = "ng = bpy.data.node_groups[\'"

    add_scrollback(m + ' --> ' + msg, 'OUTPUT')
    history_append(text=m, remove_duplicates=True)
    if not (msg == fail):
        ctx.space_data.history[-1].body = msg
def in_sverchok_commands(context, m):

    if m.startswith('_svc_'):
        bcp_justbrowse('https://github.com/nortikin/sverchok/commits/master')

    elif m.startswith('_svc'):
        # sv commits
        url = "https://api.github.com/repos/nortikin/sverchok/commits"
        github_commits(url, 5)

    elif m.startswith('times '):
        command, named_group = m.split(' ')
        if not (named_group in bpy.data.node_groups):
            pass
        else:
            get_sv_times(named_group)

    elif m == 'times':
        get_sv_times_all()

    elif m == 'get sverchok':
        get_sv()

    elif m.startswith('sv '):
        addon_name = 'sverchok'
        addon = bpy.context.user_preferences.addons.get(addon_name)
        if not addon:
            add_scrollback('sverchok not found', 'ERROR')
            # end early for sanity for the following code
            return True

        prefs = addon.preferences
        if m == 'sv blossom':
            prefs.sv_theme = 'nipon_blossom'
            bpy.ops.node.sverchok_apply_theme()
            add_scrollback('enabled nipon!', 'OUTPUT')
        elif m == 'sv icons':
            prefs.show_icons = not prefs.show_icons
            add_scrollback('set icons = {0}'.format(prefs.show_icons),
                           'OUTPUT')

    else:
        return False

    return True
def in_sverchok_commands(context, m):

    if m.startswith('_svc_'):
            bcp_justbrowse('https://github.com/nortikin/sverchok/commits/master')

    elif m.startswith('_svc'):
        # sv commits
        url = "https://api.github.com/repos/nortikin/sverchok/commits"
        github_commits(url, 5)

    elif m.startswith('times '):
        command, named_group = m.split(' ')
        if not (named_group in bpy.data.node_groups):
            pass
        else:
            get_sv_times(named_group)

    elif m == 'times':
        get_sv_times_all()

    elif m == 'get sverchok':
        get_sv()

    elif m.startswith('sv '):
        addon_name = 'sverchok'
        addon = bpy.context.user_preferences.addons.get(addon_name)
        if not addon:
            add_scrollback('sverchok not found', 'ERROR')
            # end early for sanity for the following code
            return True

        prefs = addon.preferences
        if m == 'sv blossom':
            prefs.sv_theme = 'nipon_blossom'
            bpy.ops.node.sverchok_apply_theme()
            add_scrollback('enabled nipon!', 'OUTPUT')
        elif m == 'sv icons':
            prefs.show_icons = not prefs.show_icons
            add_scrollback('set icons = {0}'.format(prefs.show_icons), 'OUTPUT')

    else:
        return False

    return True
def in_sverchok_commands(context, m):

    if m.startswith("_svc_"):
        bcp_justbrowse("https://github.com/nortikin/sverchok/commits/master")

    elif m.startswith("_svc"):
        # sv commits
        url = "https://api.github.com/repos/nortikin/sverchok/commits"
        github_commits(url, 5)

    elif m.startswith("times "):
        command, named_group = m.split(" ")
        if not (named_group in bpy.data.node_groups):
            pass
        else:
            get_sv_times(named_group)

    elif m == "times":
        get_sv_times_all()

    elif m == "get sverchok":
        get_sv()

    elif m.startswith("sv "):
        addon_name = "sverchok"
        addon = bpy.context.user_preferences.addons.get(addon_name)
        if not addon:
            add_scrollback("sverchok not found", "ERROR")
            # end early for sanity for the following code
            return True

        prefs = addon.preferences
        if m == "sv blossom":
            prefs.sv_theme = "nipon_blossom"
            bpy.ops.node.sverchok_apply_theme()
            add_scrollback("enabled nipon!", "OUTPUT")
        elif m == "sv icons":
            prefs.show_icons = not prefs.show_icons
            add_scrollback("set icons = {0}".format(prefs.show_icons), "OUTPUT")

    else:
        return False

    return True
def in_upgrade_commands(context, m):
    if m.startswith("-up "):
        # inputs            | argument result
        # ------------------+-------------------
        # -up win32         | option = ['win32']
        # -up win64 berry   | option = ['win64', 'berry']
        cmd, *option = m.split(" ")
        res = peek_builder_org(option)
        if res:
            for line in res:
                add_scrollback(line, "OUTPUT")
            add_scrollback("", "OUTPUT")

        if len(res) == 1:
            process_zip(res[0])
        else:
            msg = "too many zips, narrow down!"
            add_scrollback(msg, "INFO")
    else:
        return False

    return True
def in_upgrade_commands(context, m):
    if m.startswith("-up "):
        # inputs            | argument result
        # ------------------+-------------------
        # -up win32         | option = ['win32']
        # -up win64 berry   | option = ['win64', 'berry']
        cmd, *option = m.split(' ')
        res = peek_builder_org(option)
        if res:
            for line in res:
                add_scrollback(line, 'OUTPUT')
            add_scrollback('', 'OUTPUT')

        if len(res) == 1:
            process_zip(res[0])
        else:
            msg = 'too many zips, narrow down!'
            add_scrollback(msg, 'INFO')
    else:
        return False

    return True
def in_modeling_tools(context, m):
    if m in {"vtx", "xl"}:
        vtx_specials(self, m)

    elif m == "-dist":
        msg = distance_check()
        add_scrollback(msg, "INFO")

    elif m == "-steps":
        registers_operator = [bpy.ops.mesh, "steps_add"]
        module_to_enable = "mesh_add_steps"
        url_prefix = "https://raw.githubusercontent.com/zeffii/"
        url_repo = "rawr/master/blender/scripts/addons_contrib/"
        file_name = "mesh_add_steps.py"
        dl_url = url_prefix + url_repo + file_name

        packaged = dict(operator=registers_operator, module_to_enable=module_to_enable, url=dl_url)

        test_dl_run(packaged)

    elif m == "-debug":  # formerly -debug_mesh

        if "index_visualiser" in dir(bpy.ops.view3d):
            # bpy.ops.wm.addon_enable(module='view3d_idx_view')
            # msg = 'enabled modified debugger in N panel'
            # add_scrollback(msg, 'OUTPUT')
            return True

        registers_operator = [bpy.ops.view3d, "index_visualiser"]
        module_to_enable = "view3d_idx_view"
        url_prefix = "https://gist.githubusercontent.com/zeffii/9451340/raw"
        hasher = "/205610d27968305dfd88b0a521fe35aced83db32/"
        file_name = "view3d_idx_view.py"
        dl_url = url_prefix + hasher + file_name

        packaged = dict(operator=registers_operator, module_to_enable=module_to_enable, url=dl_url)

        test_dl_run(packaged)

    elif m == "-snaps":
        url_prefix = "https://raw.githubusercontent.com/Mano-Wii/Snap-Utilities-Line/master/"
        module_to_enable = "mesh_snap_utilities_line"
        dl_url = url_prefix + (module_to_enable + ".py")

        registers_operator = [bpy.ops.mesh, "snap_utilities_line"]

        packaged = dict(operator=registers_operator, module_to_enable=module_to_enable, url=dl_url)

        test_dl_run(packaged)

    elif m == "-or2s":
        url_prefix = "https://gist.githubusercontent.com/zeffii/"
        burp = "5844379/raw/01515bbf679f3f7a7c965d732004086dd40e64c0/"
        mod = "space_view3d_move_origin"
        dl_url = url_prefix + burp + mod + ".py"
        lazy_power_download(mod, dl_url, bpy.ops.object, "origin_to_selected")

        msg = "start with space-> Origin Move To Selected"
        add_scrollback(msg, "INFO")

    elif m == "get comprendo":
        url_prefix = "https://gist.githubusercontent.com/zeffii/"
        burp = "eff101fca227ac706d9b/raw/53360a0e4ac6af8d371ed2d91c77ea6d83e12ad0/"
        mod = "image_editor_flatten"
        dl_url = url_prefix + burp + mod + ".py"
        lazy_power_download(mod, dl_url, bpy.ops.image, "tkd_callback_operator")

        msg = "downloaded or checked if composite+render is present"
        add_scrollback(msg, "INFO")

    elif m in lazy_dict:
        try:
            f, cmd = lazy_dict[m]
            f(module=cmd)
            msg = "enabled: " + cmd
            add_scrollback(msg, "OUTPUT")
        except:
            rt = "failed to do: " + str(lazy_dict[m])

    elif m == "-itx":
        perform_face_intersection()

    elif m.startswith("enable "):
        command, addon = m.split()
        t = bpy.ops.wm.addon_enable(module=addon)
        if t == {"FINISHED"}:
            msg = "enabled {0}".format(addon)
        elif t == {"CANCELLED"}:
            msg = "addon not enabled, is it spelled correctly?"
        add_scrollback(msg, "INFO")

    elif m == "-bix2":
        do_bix2()

    else:
        return False

    return True
def in_core_dev_commands(context, m):

    if m.endswith("??"):

        m = m[:-2]
        console, stdout, stderr = get_console(hash(context.region))

        if m in console.locals.keys():
            f = str(dir(console.locals[m]))
        else:
            try:
                f = str(eval("dir({0})".format(m)))
            except:
                f = "failed to find reference.."

        add_scrollback(f, "OUTPUT")

    elif m.endswith("!"):
        """copy current line to clipboard"""
        m = m[:-1]
        context.window_manager.clipboard = m
        add_scrollback("added to clipboard", "OUTPUT")

    elif m == "ico":
        try:
            bpy.ops.wm.addon_enable(module="development_icon_get")
            add_scrollback("added icons to TextEditor", "OUTPUT")
        except:
            self.report({"INFO"}, "ico addon not present!")

    elif m == "-keys":
        write_keys_textfile()

    elif m == "syntax":
        do_text_glam()

    elif m in {"syntax lt", "syntax dk"}:
        do_text_glam()
        theme = m.split()[1]
        print("theme", theme)
        do_text_synthax(theme)

    elif m.startswith("-gist "):
        # will not upload duplicates of the same file, placed in Set first.

        if m == "-gist -o":
            # send all visible, unnamed.
            pass

        if m.startswith("-gist -o "):
            # like:  "-gist -o test_gist"
            # send all visible, try naming it.
            gname = m[9:].strip()
            gname = gname.replace(" ", "_")
            file_names = find_filenames()
            to_gist(file_names, project_name=gname, public_switch=True)

    elif m.startswith("-sel -t "):
        # starting2 not implemented yet
        # accepts:
        # '-sel -t CU CurveObj56'
        # '-sel -t CU CurveObj 56'
        # '-sel -t CURVE CurveObj 56'
        _type, *find_str = m[8:].split()
        select_starting2(" ".join(find_str), _type)

    elif m.startswith("-sel "):
        find_str = m[5:]
        select_starting(find_str)

    elif m == "-man":
        throw_manual()

    elif m == "-gh":
        import os
        import subprocess

        _root = os.path.dirname(__file__)
        f = [os.path.join(_root, "tmp", "github_start.bat")]
        subprocess.call(f)

    elif m == "bl<":
        view_types_to_console()

    elif m.startswith("!"):
        """ dispatch a threaded worker """
        cmd_controller(m[1:])

    elif m.startswith("obj=") or m.startswith("n="):
        do_console_rewriter(context, m)

    elif m == "git help":
        git_strings = (
            "git pull (--all)",
            "git push (--all)",
            "git add (--all)",
            "git add <specify file>  # do this from inside the right directory",
            'git commit -am "commit message here"',
            "git checkout -b <branch_name>  # new_branch_name_based_on_current_branch",
            "git branch -D <branch_name> # deletes branch locally (you must be on a different branch first)",
            "git branch",
            "   ",
            "-- be in master, or branch to merge into",
            "   git merge <branch_to_merge>",
            "   git push --all",
            "   ",
            "   ",
            "To reset unstaged things..:",
            "  git fetch origin",
            "  git reset --hard origin/master",
            "  git clean -f",
        )
        for line in git_strings:
            add_scrollback(line, "OUTPUT")

    else:
        return False

    return True
Exemple #26
0
def in_core_dev_commands(context, m):

    if m.endswith('??'):

        m = m[:-2]
        console, stdout, stderr = get_console(hash(context.region))

        if m in console.locals.keys():
            f = str(dir(console.locals[m]))
        else:
            try:
                f = str(eval('dir({0})'.format(m)))
            except:
                f = 'failed to find reference..'

        add_scrollback(f, 'OUTPUT')

    elif m.endswith('!'):
        '''copy current line to clipboard'''
        m = m[:-1]
        context.window_manager.clipboard = m
        add_scrollback('added to clipboard', 'OUTPUT')

    elif m == 'ico':
        try:
            bpy.ops.wm.addon_enable(module="development_icon_get")
            add_scrollback('added icons to TextEditor', 'OUTPUT')
        except:
            self.report({'INFO'}, "ico addon not present!")

    elif m == '-keys':
        write_keys_textfile()

    elif m == 'syntax':
        do_text_glam()

    elif m in {'syntax lt', 'syntax dk'}:
        do_text_glam()
        theme = m.split()[1]
        print('theme', theme)
        do_text_synthax(theme)

    elif m.startswith('-gist '):
        # will not upload duplicates of the same file, placed in Set first.

        if m == '-gist -o':
            # send all visible, unnamed.
            pass

        if m.startswith('-gist -o '):
            # like:  "-gist -o test_gist"
            # send all visible, try naming it.
            gname = m[9:].strip()
            gname = gname.replace(' ', '_')
            file_names = find_filenames()
            to_gist(file_names, project_name=gname, public_switch=True)

    elif m.startswith('-sel -t '):
        # starting2 not implemented yet
        # accepts:
        # '-sel -t CU CurveObj56'
        # '-sel -t CU CurveObj 56'
        # '-sel -t CURVE CurveObj 56'
        _type, *find_str = m[8:].split()
        select_starting2(' '.join(find_str), _type)

    elif m.startswith('-sel '):
        find_str = m[5:]
        select_starting(find_str)

    elif m == "-man":
        throw_manual()

    elif m == '-gh':
        import os
        import subprocess
        _root = os.path.dirname(__file__)
        f = [os.path.join(_root, 'tmp', 'github_start.bat')]
        subprocess.call(f)

    elif m == 'bl<':
        view_types_to_console()

    elif m.startswith("!"):
        ''' dispatch a threaded worker '''
        cmd_controller(m[1:])

    else:
        return False

    return True
Exemple #27
0
def in_scene_commands(context, m):
    if m == "cen":
        '''cursor to center'''
        context.scene.cursor_location = (0.0, 0.0, 0.0)

    if m == 'cenv':
        context.scene.cursor_location = (0.0, 0.0, 0.0)
        align_view_to_3dcursor()

    elif m == 'cento':
        center_to_selected(context)

    elif m.startswith("cen="):
        '''
        cursor to coordinate, anything that can be evalled..
        eg: cen=bpy.data.objects[1].data.verts[1].co

        '''
        right = m.split('=')[1]
        context.scene.cursor_location = eval(right)

    elif m == 'wipe':
        remove_obj_and_mesh(context)
        add_scrollback('wiped objects and meshes', 'OUTPUT')
        # history_append(text=m, current_character=0, remove_duplicates=True)
        history_append(text=m, remove_duplicates=True)

    elif m == 'wipe+':
        remove_obj_and_mesh(context)
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback('wiped objects, meshes, and materials', 'OUTPUT')
        history_append(text=m, remove_duplicates=True)

    elif m == 'wipem':
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback('wiped materials only', 'OUTPUT')
        history_append(text=m, remove_duplicates=True)

    elif m in {'tt', 'tb'}:
        prefs = context.user_preferences
        method = {'tb': 'TRACKBALL', 'tt': 'TURNTABLE'}.get(m)
        prefs.inputs.view_rotate_method = method
        msg = 'set rotation_method to {0} ({1})'.format(method, m)
        add_scrollback(msg, 'OUTPUT')

    elif m == '123':
        set_keymap()
        add_scrollback('enabled: 1=VERT_SEL, 2=EDGE_SEL, 3=FACE_SEL', 'OUTPUT')

    elif m == 'mesh2json':
        add_mesh_2_json('zup')
        add_scrollback(
            'added mesh 2 json script to text editor! remember to triangulate first',
            'OUTPUT')

    elif m == 'mesh2json2':
        add_mesh_2_json('yup')
        add_scrollback(
            'added mesh 2 json (y up) script to text editor! remember to triangulate first',
            'OUTPUT')

    elif m.startswith('v2rdim'):
        SCN = bpy.context.scene
        SE = SCN.sequence_editor

        if m == 'v2rdim':
            sequence = SE.active_strip
        elif m.startswith('v2rdim '):
            vidname = m[7:]
            sequence = SE.sequences.get(vidname)
            if not sequence:
                print(vidname, 'is not a sequence - check the spelling')
                return True

        def get_size(sequence):
            clips = bpy.data.movieclips
            fp = sequence.filepath
            mv = clips.load(fp)
            x, y = mv.size[:]
            clips.remove(mv)
            return x, y

        x, y = get_size(sequence)
        SCN.render.resolution_x = x
        SCN.render.resolution_y = y
        SCN.render.resolution_percentage = 100

    elif m in {'crop to active', 'cta'}:
        se = bpy.context.scene.sequence_editor
        start = se.active_strip.frame_start
        duration = se.active_strip.frame_duration
        bpy.context.scene.frame_start = start
        bpy.context.scene.frame_end = start + duration

    elif m.startswith("gif ") and (len(m) > 5):
        make_animated_gif(m[4:])

    elif m == 'sel lights':
        for o in bpy.data.objects:
            if o.type == 'LAMP':
                o.select = True

    elif m == 'rm lights':
        objs = bpy.data.objects
        named_lights = []
        for o in objs:
            if o.type == 'LAMP':
                named_lights.append(o.name)
        for n in named_lights:
            o = objs[n]
            o.user_clear()
            bpy.context.scene.objects.unlink(o)
            objs.remove(o)

    elif m in {'frame_end = frame_current', 'fend=fcur', 'fc'}:
        scn = bpy.context.scene
        scn.frame_end = scn.frame_current

    elif m == 'psel':
        new_empty = parent_selected_to_new_empty()
        if new_empty:
            msg = 'parented selected to {0}'
            msg = msg.format(new_empty.name)
            output_type = 'OUTPUT'
        else:
            msg = 'no objects selected to parent to'
            output_type = 'ERROR'
        add_scrollback(msg, output_type)

    else:
        return False

    return True
def in_scene_commands(context, m):
    if m == "cen":
        """cursor to center"""
        context.scene.cursor_location = (0.0, 0.0, 0.0)

    if m == "cenv":
        context.scene.cursor_location = (0.0, 0.0, 0.0)
        align_view_to_3dcursor()

    elif m == "cento":
        center_to_selected(context)

    elif m.startswith("cen="):
        """
        cursor to coordinate, anything that can be evalled..
        eg: cen=bpy.data.objects[1].data.verts[1].co

        """
        right = m.split("=")[1]
        context.scene.cursor_location = eval(right)

    elif m == "wipe":
        remove_obj_and_mesh(context)
        add_scrollback("wiped objects and meshes", "OUTPUT")
        # history_append(text=m, current_character=0, remove_duplicates=True)
        history_append(text=m, remove_duplicates=True)

    elif m == "wipe+":
        remove_obj_and_mesh(context)
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback("wiped objects, meshes, and materials", "OUTPUT")
        history_append(text=m, remove_duplicates=True)

    elif m == "wipem":
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback("wiped materials only", "OUTPUT")
        history_append(text=m, remove_duplicates=True)

    elif m in {"tt", "tb"}:
        prefs = context.user_preferences
        method = {"tb": "TRACKBALL", "tt": "TURNTABLE"}.get(m)
        prefs.inputs.view_rotate_method = method
        msg = "set rotation_method to {0} ({1})".format(method, m)
        add_scrollback(msg, "OUTPUT")

    elif m == "123":
        set_keymap()
        add_scrollback("enabled: 1=VERT_SEL, 2=EDGE_SEL, 3=FACE_SEL", "OUTPUT")

    elif m == "mesh2json":
        add_mesh_2_json("zup")
        add_scrollback("added mesh 2 json script to text editor! remember to triangulate first", "OUTPUT")

    elif m == "mesh2json2":
        add_mesh_2_json("yup")
        add_scrollback("added mesh 2 json (y up) script to text editor! remember to triangulate first", "OUTPUT")

    elif m == "v2rdim":
        v2rdim()

    elif m in {"crop to active", "cta"}:
        crop_to_active()

    elif m == "dandc":
        v2rdim()
        crop_to_active()
        add_scrollback("set render dims and cropped timeline", "OUTPUT")

    elif m.startswith("anim "):
        fp = m[5:]
        add_scrollback("going to render to " + fp, "OUTPUT")
        render_to_filepath(fp)

    elif m.startswith("gif ") and (len(m) > 5):
        make_animated_gif(m[4:])

    elif m.startswith("ogif ") and (len(m) > 6):
        make_optimized_animated_gif(m[5:])

    elif m.startswith("sizeof"):
        process_size_query(m)

    elif m == "sel lights":
        for o in bpy.data.objects:
            if o.type == "LAMP":
                o.select = True

    elif m == "rm lights":
        objs = bpy.data.objects
        named_lights = []
        for o in objs:
            if o.type == "LAMP":
                named_lights.append(o.name)
        for n in named_lights:
            o = objs[n]
            o.user_clear()
            bpy.context.scene.objects.unlink(o)
            objs.remove(o)

    elif m in {"frame_end = frame_current", "fend=fcur", "fc"}:
        scn = bpy.context.scene
        scn.frame_end = scn.frame_current

    elif m == "psel":
        new_empty = parent_selected_to_new_empty()
        if new_empty:
            msg = "parented selected to {0}"
            msg = msg.format(new_empty.name)
            output_type = "OUTPUT"
        else:
            msg = "no objects selected to parent to"
            output_type = "ERROR"
        add_scrollback(msg, output_type)

    elif m in {"nodeview white", "nv white", "nv111"}:
        current_theme = bpy.context.user_preferences.themes.items()[0][0]
        editor = bpy.context.user_preferences.themes[current_theme].node_editor
        editor.space.back = (1, 1, 1)

    elif m in {"3dv easy", "3de", "sde"}:
        current_theme = bpy.context.user_preferences.themes.items()[0][0]
        editor = bpy.context.user_preferences.themes[current_theme].view_3d
        editor.grid = [0.533277, 0.533277, 0.533277]
        editor.space.gradients.show_grad = False
        editor.space.gradients.high_gradient = [0.701102, 0.701102, 0.701102]
    else:
        return False

    return True
def in_core_dev_commands(context, m):

    if m.endswith('??'):

        m = m[:-2]
        console, stdout, stderr = get_console(hash(context.region))

        if m in console.locals.keys():
            f = str(dir(console.locals[m]))
        else:
            try:
                f = str(eval('dir({0})'.format(m)))
            except:
                f = 'failed to find reference..'

        add_scrollback(f, 'OUTPUT')

    elif m.endswith('!'):
        '''copy current line to clipboard'''
        m = m[:-1]
        context.window_manager.clipboard = m
        add_scrollback('added to clipboard', 'OUTPUT')

    elif m == 'ico':
        try:
            bpy.ops.wm.addon_enable(module="development_icon_get")
            add_scrollback('added icons to TextEditor', 'OUTPUT')
        except:
            self.report({'INFO'}, "ico addon not present!")

    elif m == '-keys':
        write_keys_textfile()

    elif m == 'syntax':
        do_text_glam()

    elif m in {'syntax lt', 'syntax dk'}:
        do_text_glam()
        theme = m.split()[1]
        print('theme', theme)
        do_text_synthax(theme)

    elif m.startswith('-gist '):
        # will not upload duplicates of the same file, placed in Set first.

        if m == '-gist -o':
            # send all visible, unnamed.
            pass

        if m.startswith('-gist -o '):
            # like:  "-gist -o test_gist"
            # send all visible, try naming it.
            gname = m[9:].strip()
            gname = gname.replace(' ', '_')
            file_names = find_filenames()
            to_gist(file_names, project_name=gname, public_switch=True)

    elif m.startswith('-sel -t '):
        # starting2 not implemented yet
        # accepts:
        # '-sel -t CU CurveObj56'
        # '-sel -t CU CurveObj 56'
        # '-sel -t CURVE CurveObj 56'
        _type, *find_str = m[8:].split()
        select_starting2(' '.join(find_str), _type)

    elif m.startswith('-sel '):
        find_str = m[5:]
        select_starting(find_str)

    elif m == "-man":
        throw_manual()

    elif m == '-gh':
        import os
        import subprocess
        _root = os.path.dirname(__file__)
        f = [os.path.join(_root, 'tmp', 'github_start.bat')]
        subprocess.call(f)

    elif m == 'bl<':
        view_types_to_console()

    elif m.startswith("!"):
        ''' dispatch a threaded worker '''
        cmd_controller(m[1:])

    elif m.startswith('obj=') or m.startswith('n='):
        do_console_rewriter(context, m)

    elif m == 'git help':
        git_strings = (
            "git pull (--all)", "git push (--all)", "git add (--all)",
            "git add <specify file>  # do this from inside the right directory",
            "git commit -am \"commit message here\"",
            "git checkout -b <branch_name>  # new_branch_name_based_on_current_branch",
            "git branch -D <branch_name> # deletes branch locally (you must be on a different branch first)",
            "git branch", "   ", "-- be in master, or branch to merge into",
            "   git merge <branch_to_merge>", "   git push --all", "   ",
            "   ", "To reset unstaged things..:", "  git fetch origin",
            "  git reset --hard origin/master", "  git clean -f")
        for line in git_strings:
            add_scrollback(line, 'OUTPUT')

    else:
        return False

    return True
def in_core_dev_commands(context, m):

    if m.endswith('??'):

        m = m[:-2]
        console, stdout, stderr = get_console(hash(context.region))

        if m in console.locals.keys():
            f = str(dir(console.locals[m]))
        else:
            try:
                f = str(eval('dir({0})'.format(m)))
            except:
                f = 'failed to find reference..'

        add_scrollback(f, 'OUTPUT')

    elif m.endswith('!'):
        '''copy current line to clipboard'''
        m = m[:-1]
        context.window_manager.clipboard = m
        add_scrollback('added to clipboard', 'OUTPUT')

    elif m == 'ico':
        try:
            bpy.ops.wm.addon_enable(module="development_icon_get")
            add_scrollback('added icons to TextEditor', 'OUTPUT')
        except:
            self.report({'INFO'}, "ico addon not present!")

    elif m == '-keys':
        write_keys_textfile()

    elif m == 'syntax':
        do_text_glam()

    elif m in {'syntax lt', 'syntax dk'}:
        do_text_glam()
        theme = m.split()[1]
        print('theme', theme)
        do_text_synthax(theme)

    elif m.startswith('-gist '):
        # will not upload duplicates of the same file, placed in Set first.

        if m == '-gist -o':
            # send all visible, unnamed.
            pass

        if m.startswith('-gist -o '):
            # like:  "-gist -o test_gist"
            # send all visible, try naming it.
            gname = m[9:].strip()
            gname = gname.replace(' ', '_')
            file_names = find_filenames()
            to_gist(file_names, project_name=gname, public_switch=True)

    elif m.startswith('-sel -t '):
        # starting2 not implemented yet
        # accepts:
        # '-sel -t CU CurveObj56'
        # '-sel -t CU CurveObj 56'
        # '-sel -t CURVE CurveObj 56'
        _type, *find_str = m[8:].split()
        select_starting2(' '.join(find_str), _type)

    elif m.startswith('-sel '):
        find_str = m[5:]
        select_starting(find_str)

    elif m == "-man":
        throw_manual()

    elif m == '-gh':
        import os
        import subprocess
        _root = os.path.dirname(__file__)
        f = [os.path.join(_root, 'tmp', 'github_start.bat')]
        subprocess.call(f)

    elif m == 'bl<':
        view_types_to_console()

    elif m.startswith("!"):
        ''' dispatch a threaded worker '''
        cmd_controller(m[1:])

    else:
        return False

    return True
def in_modeling_tools(context, m):
    if m in {'vtx', 'xl'}:
        vtx_specials(self, m)

    elif m == '-dist':
        msg = distance_check()
        add_scrollback(msg, 'INFO')

    elif m == '-steps':
        registers_operator = [bpy.ops.mesh, 'steps_add']
        module_to_enable = 'mesh_add_steps'
        url_prefix = 'https://raw.githubusercontent.com/zeffii/'
        url_repo = 'rawr/master/blender/scripts/addons_contrib/'
        file_name = 'mesh_add_steps.py'
        dl_url = url_prefix + url_repo + file_name

        packaged = dict(
            operator=registers_operator,
            module_to_enable=module_to_enable,
            url=dl_url
        )

        test_dl_run(packaged)

    elif m == '-debug':  # formerly -debug_mesh

        if 'index_visualiser' in dir(bpy.ops.view3d):
            # bpy.ops.wm.addon_enable(module='view3d_idx_view')
            # msg = 'enabled modified debugger in N panel'
            # add_scrollback(msg, 'OUTPUT')
            return True

        registers_operator = [bpy.ops.view3d, 'index_visualiser']
        module_to_enable = 'view3d_idx_view'
        url_prefix = 'https://gist.githubusercontent.com/zeffii/9451340/raw'
        hasher = '/205610d27968305dfd88b0a521fe35aced83db32/'
        file_name = 'view3d_idx_view.py'
        dl_url = url_prefix + hasher + file_name

        packaged = dict(
            operator=registers_operator,
            module_to_enable=module_to_enable,
            url=dl_url
        )

        test_dl_run(packaged)

    elif m == '-snaps':
        url_prefix = "https://raw.githubusercontent.com/Mano-Wii/Snap-Utilities-Line/master/"
        module_to_enable = "mesh_snap_utilities_line"
        dl_url = url_prefix + (module_to_enable + '.py')

        registers_operator = [bpy.ops.mesh, 'snap_utilities_line']

        packaged = dict(
            operator=registers_operator,
            module_to_enable=module_to_enable,
            url=dl_url
        )

        test_dl_run(packaged)

    elif m == '-or2s':
        url_prefix = "https://gist.githubusercontent.com/zeffii/"
        burp = "5844379/raw/01515bbf679f3f7a7c965d732004086dd40e64c0/"
        mod = "space_view3d_move_origin"
        dl_url = url_prefix + burp + mod + '.py'
        lazy_power_download(mod, dl_url, bpy.ops.object, 'origin_to_selected')

        msg = 'start with space-> Origin Move To Selected'
        add_scrollback(msg, 'INFO')

    elif m == 'get comprendo':
        url_prefix = "https://gist.githubusercontent.com/zeffii/"
        burp = "eff101fca227ac706d9b/raw/53360a0e4ac6af8d371ed2d91c77ea6d83e12ad0/"
        mod = "image_editor_flatten"
        dl_url = url_prefix + burp + mod + '.py'
        lazy_power_download(mod, dl_url, bpy.ops.image, 'tkd_callback_operator')

        msg = 'downloaded or checked if composite+render is present'
        add_scrollback(msg, 'INFO')

    elif m in lazy_dict:
        try:
            f, cmd = lazy_dict[m]
            f(module=cmd)
            msg = 'enabled: ' + cmd
            add_scrollback(msg, 'OUTPUT')
        except:
            rt = 'failed to do: ' + str(lazy_dict[m])

    elif m == '-itx':
        perform_face_intersection()

    elif m.startswith('enable '):
        command, addon = m.split()
        t = bpy.ops.wm.addon_enable(module=addon)
        if t == {'FINISHED'}:
            msg = 'enabled {0}'.format(addon)
        elif t == {'CANCELLED'}:
            msg = 'addon not enabled, is it spelled correctly?'
        add_scrollback(msg, 'INFO')

    elif m == '-bix2':
        do_bix2()

    else:
        return False

    return True
def in_modeling_tools(context, m):
    if m in {'vtx', 'xl'}:
        vtx_specials(self, m)

    elif m == '-dist':
        msg = distance_check()
        add_scrollback(msg, 'INFO')

    elif m == '-steps':
        registers_operator = [bpy.ops.mesh, 'steps_add']
        module_to_enable = 'mesh_add_steps'
        url_prefix = 'https://raw.githubusercontent.com/zeffii/'
        url_repo = 'rawr/master/blender/scripts/addons_contrib/'
        file_name = 'mesh_add_steps.py'
        dl_url = url_prefix + url_repo + file_name

        packaged = dict(operator=registers_operator,
                        module_to_enable=module_to_enable,
                        url=dl_url)

        test_dl_run(packaged)

    elif m == '-debug':  # formerly -debug_mesh

        if 'index_visualiser' in dir(bpy.ops.view3d):
            # bpy.ops.wm.addon_enable(module='view3d_idx_view')
            # msg = 'enabled modified debugger in N panel'
            # add_scrollback(msg, 'OUTPUT')
            return True

        registers_operator = [bpy.ops.view3d, 'index_visualiser']
        module_to_enable = 'view3d_idx_view'
        url_prefix = 'https://gist.githubusercontent.com/zeffii/9451340/raw'
        hasher = '/205610d27968305dfd88b0a521fe35aced83db32/'
        file_name = 'view3d_idx_view.py'
        dl_url = url_prefix + hasher + file_name

        packaged = dict(operator=registers_operator,
                        module_to_enable=module_to_enable,
                        url=dl_url)

        test_dl_run(packaged)

    elif m == '-snaps':
        url_prefix = "https://raw.githubusercontent.com/Mano-Wii/Snap-Utilities-Line/master/"
        module_to_enable = "mesh_snap_utilities_line"
        dl_url = url_prefix + (module_to_enable + '.py')

        registers_operator = [bpy.ops.mesh, 'snap_utilities_line']

        packaged = dict(operator=registers_operator,
                        module_to_enable=module_to_enable,
                        url=dl_url)

        test_dl_run(packaged)

    elif m == '-or2s':
        url_prefix = "https://gist.githubusercontent.com/zeffii/"
        burp = "5844379/raw/01515bbf679f3f7a7c965d732004086dd40e64c0/"
        mod = "space_view3d_move_origin"
        dl_url = url_prefix + burp + mod + '.py'
        lazy_power_download(mod, dl_url, bpy.ops.object, 'origin_to_selected')

        msg = 'start with space-> Origin Move To Selected'
        add_scrollback(msg, 'INFO')

    elif m == 'get comprendo':
        url_prefix = "https://gist.githubusercontent.com/zeffii/"
        burp = "eff101fca227ac706d9b/raw/53360a0e4ac6af8d371ed2d91c77ea6d83e12ad0/"
        mod = "image_editor_flatten"
        dl_url = url_prefix + burp + mod + '.py'
        lazy_power_download(mod, dl_url, bpy.ops.image,
                            'tkd_callback_operator')

        msg = 'downloaded or checked if composite+render is present'
        add_scrollback(msg, 'INFO')

    elif m in lazy_dict:
        try:
            f, cmd = lazy_dict[m]
            f(module=cmd)
            msg = 'enabled: ' + cmd
            add_scrollback(msg, 'OUTPUT')
        except:
            rt = 'failed to do: ' + str(lazy_dict[m])

    elif m == '-itx':
        perform_face_intersection()

    elif m.startswith('enable '):
        command, addon = m.split()
        t = bpy.ops.wm.addon_enable(module=addon)
        if t == {'FINISHED'}:
            msg = 'enabled {0}'.format(addon)
        elif t == {'CANCELLED'}:
            msg = 'addon not enabled, is it spelled correctly?'
        add_scrollback(msg, 'INFO')

    elif m == '-bix2':
        do_bix2()

    else:
        return False

    return True
def in_scene_commands(context, m):
    if m == "cen":
        '''cursor to center'''
        context.scene.cursor_location = (0.0, 0.0, 0.0)

    if m == 'cenv':
        context.scene.cursor_location = (0.0, 0.0, 0.0)
        align_view_to_3dcursor()

    elif m == 'cento':
        center_to_selected(context)

    elif m.startswith("cen="):
        '''
        cursor to coordinate, anything that can be evalled..
        eg: cen=bpy.data.objects[1].data.verts[1].co

        '''
        right = m.split('=')[1]
        context.scene.cursor_location = eval(right)

    elif m == 'wipe':
        remove_obj_and_mesh(context)
        add_scrollback('wiped objects and meshes', 'OUTPUT')
        # history_append(text=m, current_character=0, remove_duplicates=True)
        history_append(text=m, remove_duplicates=True)

    elif m == 'wipe+':
        remove_obj_and_mesh(context)
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback('wiped objects, meshes, and materials', 'OUTPUT')
        history_append(text=m, remove_duplicates=True)

    elif m == 'wipem':
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback('wiped materials only', 'OUTPUT')
        history_append(text=m, remove_duplicates=True)

    elif m in {'tt', 'tb'}:
        prefs = context.user_preferences
        method = {'tb': 'TRACKBALL', 'tt': 'TURNTABLE'}.get(m)
        prefs.inputs.view_rotate_method = method
        msg = 'set rotation_method to {0} ({1})'.format(method, m)
        add_scrollback(msg, 'OUTPUT')

    elif m == '123':
        set_keymap()
        add_scrollback('enabled: 1=VERT_SEL, 2=EDGE_SEL, 3=FACE_SEL', 'OUTPUT')

    elif m == 'mesh2json':
        add_mesh_2_json('zup')
        add_scrollback('added mesh 2 json script to text editor! remember to triangulate first', 'OUTPUT')

    elif m == 'mesh2json2':
        add_mesh_2_json('yup')
        add_scrollback('added mesh 2 json (y up) script to text editor! remember to triangulate first', 'OUTPUT')

    elif m.startswith('v2rdim'):
        SCN = bpy.context.scene
        SE = SCN.sequence_editor

        if m == 'v2rdim':
            sequence = SE.active_strip
        elif m.startswith('v2rdim '):
            vidname = m[7:]
            sequence = SE.sequences.get(vidname)
            if not sequence:
                print(vidname, 'is not a sequence - check the spelling')
                return True

        def get_size(sequence):
            clips = bpy.data.movieclips
            fp = sequence.filepath
            mv = clips.load(fp)
            x, y = mv.size[:]
            clips.remove(mv)
            return x, y

        x, y = get_size(sequence)
        SCN.render.resolution_x = x
        SCN.render.resolution_y = y
        SCN.render.resolution_percentage = 100

    elif m in {'crop to active', 'cta'}:
        se = bpy.context.scene.sequence_editor
        start = se.active_strip.frame_start
        duration = se.active_strip.frame_duration
        bpy.context.scene.frame_start = start
        bpy.context.scene.frame_end = start + duration

    elif m.startswith("gif ") and (len(m) > 5):
        make_animated_gif(m[4:])

    elif m == 'sel lights':
        for o in bpy.data.objects:
            if o.type == 'LAMP':
                o.select = True

    elif m == 'rm lights':
        objs = bpy.data.objects
        named_lights = []
        for o in objs:
            if o.type == 'LAMP':
                named_lights.append(o.name)
        for n in named_lights:
            o = objs[n]
            o.user_clear()
            bpy.context.scene.objects.unlink(o)
            objs.remove(o)

    elif m in {'frame_end = frame_current', 'fend=fcur', 'fc'}:
        scn = bpy.context.scene
        scn.frame_end = scn.frame_current

    elif m == 'psel':
        new_empty = parent_selected_to_new_empty()
        if new_empty:
            msg = 'parented selected to {0}'
            msg = msg.format(new_empty.name)
            output_type = 'OUTPUT'
        else:
            msg = 'no objects selected to parent to'
            output_type = 'ERROR'
        add_scrollback(msg, output_type)

    else:
        return False

    return True
def in_scene_commands(context, m):
    if m == "cen":
        '''cursor to center'''
        context.scene.cursor_location = (0.0, 0.0, 0.0)

    if m == 'cenv':
        context.scene.cursor_location = (0.0, 0.0, 0.0)
        align_view_to_3dcursor()

    elif m == 'cento':
        center_to_selected(context)

    elif m.startswith("cen="):
        '''
        cursor to coordinate, anything that can be evalled..
        eg: cen=bpy.data.objects[1].data.verts[1].co

        '''
        right = m.split('=')[1]
        context.scene.cursor_location = eval(right)

    elif m == 'wipe':
        remove_obj_and_mesh(context)
        add_scrollback('wiped objects and meshes', 'OUTPUT')
        # history_append(text=m, current_character=0, remove_duplicates=True)
        history_append(text=m, remove_duplicates=True)

    elif m == 'wipe+':
        remove_obj_and_mesh(context)
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback('wiped objects, meshes, and materials', 'OUTPUT')
        history_append(text=m, remove_duplicates=True)

    elif m == 'wipem':
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback('wiped materials only', 'OUTPUT')
        history_append(text=m, remove_duplicates=True)

    elif m in {'tt', 'tb'}:
        prefs = context.user_preferences
        method = {'tb': 'TRACKBALL', 'tt': 'TURNTABLE'}.get(m)
        prefs.inputs.view_rotate_method = method
        msg = 'set rotation_method to {0} ({1})'.format(method, m)
        add_scrollback(msg, 'OUTPUT')

    elif m == '123':
        set_keymap()
        add_scrollback('enabled: 1=VERT_SEL, 2=EDGE_SEL, 3=FACE_SEL', 'OUTPUT')

    elif m == 'mesh2json':
        add_mesh_2_json('zup')
        add_scrollback(
            'added mesh 2 json script to text editor! remember to triangulate first',
            'OUTPUT')

    elif m == 'mesh2json2':
        add_mesh_2_json('yup')
        add_scrollback(
            'added mesh 2 json (y up) script to text editor! remember to triangulate first',
            'OUTPUT')

    elif m == 'v2rdim':
        v2rdim()

    elif m in {'crop to active', 'cta'}:
        crop_to_active()

    elif m == 'dandc':
        v2rdim()
        crop_to_active()
        add_scrollback('set render dims and cropped timeline', 'OUTPUT')

    elif m.startswith('anim '):
        fp = m[5:]
        add_scrollback('going to render to ' + fp, 'OUTPUT')
        render_to_filepath(fp)

    elif m.startswith("gif ") and (len(m) > 5):
        make_animated_gif(m[4:])

    elif m.startswith("ogif ") and (len(m) > 6):
        make_optimized_animated_gif(m[5:])

    elif m.startswith('sizeof'):
        process_size_query(m)

    elif m == 'sel lights':
        for o in bpy.data.objects:
            if o.type == 'LAMP':
                o.select = True

    elif m == 'rm lights':
        objs = bpy.data.objects
        named_lights = []
        for o in objs:
            if o.type == 'LAMP':
                named_lights.append(o.name)
        for n in named_lights:
            o = objs[n]
            o.user_clear()
            bpy.context.scene.objects.unlink(o)
            objs.remove(o)

    elif m in {'frame_end = frame_current', 'fend=fcur', 'fc'}:
        scn = bpy.context.scene
        scn.frame_end = scn.frame_current

    elif m == 'psel':
        new_empty = parent_selected_to_new_empty()
        if new_empty:
            msg = 'parented selected to {0}'
            msg = msg.format(new_empty.name)
            output_type = 'OUTPUT'
        else:
            msg = 'no objects selected to parent to'
            output_type = 'ERROR'
        add_scrollback(msg, output_type)

    elif m in {'nodeview white', 'nv white', 'nv111'}:
        current_theme = bpy.context.user_preferences.themes.items()[0][0]
        editor = bpy.context.user_preferences.themes[current_theme].node_editor
        editor.space.back = (1, 1, 1)

    elif m in {'3dv easy', '3de', 'sde'}:
        current_theme = bpy.context.user_preferences.themes.items()[0][0]
        editor = bpy.context.user_preferences.themes[current_theme].view_3d
        editor.grid = [0.533277, 0.533277, 0.533277]
        editor.space.gradients.show_grad = False
        editor.space.gradients.high_gradient = [0.701102, 0.701102, 0.701102]
    else:
        return False

    return True
def in_scene_commands(context, m):
    if m == "cen":
        '''cursor to center'''
        context.scene.cursor_location = (0.0, 0.0, 0.0)

    if m == 'cenv':
        context.scene.cursor_location = (0.0, 0.0, 0.0)
        align_view_to_3dcursor()

    elif m == 'cento':
        center_to_selected(context)

    elif m.startswith("cen="):
        '''
        cursor to coordinate, anything that can be evalled..
        eg: cen=bpy.data.objects[1].data.verts[1].co

        '''
        right = m.split('=')[1]
        context.scene.cursor_location = eval(right)

    elif m == 'wipe':
        remove_obj_and_mesh(context)
        add_scrollback('wiped objects and meshes', 'OUTPUT')
        # history_append(text=m, current_character=0, remove_duplicates=True)
        history_append(text=m, remove_duplicates=True)

    elif m == 'wipe+':
        remove_obj_and_mesh(context)
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback('wiped objects, meshes, and materials', 'OUTPUT')
        history_append(text=m, remove_duplicates=True)

    elif m == 'wipem':
        [bpy.data.materials.remove(i) for i in bpy.data.materials]
        add_scrollback('wiped materials only', 'OUTPUT')
        history_append(text=m, remove_duplicates=True)

    elif m in {'tt', 'tb'}:
        prefs = context.user_preferences
        method = {'tb': 'TRACKBALL', 'tt': 'TURNTABLE'}.get(m)
        prefs.inputs.view_rotate_method = method
        msg = 'set rotation_method to {0} ({1})'.format(method, m)
        add_scrollback(msg, 'OUTPUT')

    elif m == '123':
        set_keymap()
        add_scrollback('enabled: 1=VERT_SEL, 2=EDGE_SEL, 3=FACE_SEL', 'OUTPUT')

    elif m == 'mesh2json':
        add_mesh_2_json('zup')
        add_scrollback('added mesh 2 json script to text editor! remember to triangulate first', 'OUTPUT')

    elif m == 'mesh2json2':
        add_mesh_2_json('yup')
        add_scrollback('added mesh 2 json (y up) script to text editor! remember to triangulate first', 'OUTPUT')

    elif m == 'v2rdim':
        v2rdim()

    elif m in {'crop to active', 'cta'}:
        crop_to_active()

    elif m == 'dandc':
        v2rdim()
        crop_to_active()
        add_scrollback('set render dims and cropped timeline', 'OUTPUT')

    elif m.startswith('anim '):
        fp = m[5:]
        add_scrollback('going to render to ' + fp, 'OUTPUT')
        render_to_filepath(fp)

    elif m.startswith("gif ") and (len(m) > 5):
        make_animated_gif(m[4:])

    elif m.startswith("ogif ") and (len(m) > 6):
        make_optimized_animated_gif(m[5:])

    elif m.startswith('sizeof'):
        process_size_query(m)

    elif m == 'sel lights':
        for o in bpy.data.objects:
            if o.type == 'LAMP':
                o.select = True

    elif m == 'rm lights':
        objs = bpy.data.objects
        named_lights = []
        for o in objs:
            if o.type == 'LAMP':
                named_lights.append(o.name)
        for n in named_lights:
            o = objs[n]
            o.user_clear()
            bpy.context.scene.objects.unlink(o)
            objs.remove(o)

    elif m in {'frame_end = frame_current', 'fend=fcur', 'fc'}:
        scn = bpy.context.scene
        scn.frame_end = scn.frame_current

    elif m == 'psel':
        new_empty = parent_selected_to_new_empty()
        if new_empty:
            msg = 'parented selected to {0}'
            msg = msg.format(new_empty.name)
            output_type = 'OUTPUT'
        else:
            msg = 'no objects selected to parent to'
            output_type = 'ERROR'
        add_scrollback(msg, output_type)

    elif m == 'nodeview white':
        current_theme = bpy.context.user_preferences.themes.items()[0][0]
        editor = bpy.context.user_preferences.themes[current_theme].node_editor
        editor.space.back = (1, 1, 1)

    else:
        return False

    return True