Пример #1
0
    def execute(self, context):
        self.report({'INFO'}, "Selected: %s" % self.selected_task)
        new_task = alc.scene_object()

        task_version = new_task.copy(task=self.selected_task)
        task_version_dir = task_version.copy(filename='')
        new_version = task_version_dir.new_minor_version_object()
        if os.path.isdir(new_version.path_root):
            new_version = new_version.new_minor_version_object()

        else:
            new_version = new_version.copy(major='000', minor='000')
        os.makedirs(new_version.path_root)
        alc.save_file_as(new_version.copy(set_proper_filename=True).path_root)
        alc.open_file(new_version.copy(set_proper_filename=True).path_root)
        if os.path.isfile(alc.scene_object().copy(extension='json').path_root):
            print("______________Json File Saved____________")
            copyfile(
                alc.scene_object().copy(extension='json').path_root,
                new_version.copy(set_proper_filename=True,
                                 ext='json').path_root)
        else:
            print("______________No Json File on: ____________")
            print(alc.scene_object().copy(extension='json').path_root)

        return {'FINISHED'}
Пример #2
0
    def execute(self, context):
        # my_users =  bpy.props.EnumProperty(items = split_string(self.my_string))

        path_object = get_asset_from_name(
            bpy.types.Scene.scene_enum.replace('publish', self.users))
        correctName = '%s_%s_%s.blend' % (
            path_object.seq,
            path_object.shot,
            path_object.task,
        )
        path_object = path_object.copy(filename=correctName)
        open_file = path_object.latest_version().copy(
            set_proper_filename=True).path_root

        message = 'selected {}'.format(open_file)
        if os.path.isfile(open_file):
            alc.open_file(open_file)
        else:

            # alc.confirm_prompt(message='this file has an incorrect file name, consider  opening it and renaming it
            # on the utils')
            # alc.PathObject(open_file).show_in_folder()
            open_available_file(open_file)

        self.report({'INFO'}, message)

        return {'FINISHED'}
Пример #3
0
 def execute(self, context):
     self.report({'INFO'}, "Selected: %s" % self.selected_task)
     new_user = alc.scene_object().copy(
         task=self.selected_task, user='******',
         set_proper_filename=True).latest_version().path_root
     alc.open_file(new_user)
     return {'FINISHED'}
Пример #4
0
    def execute(self, context):
        self.report({'INFO'}, "Selected: %s" % self.selected_versions)
        new_user = alc.scene_object().copy(
            version=self.selected_versions).path_root
        import os

        if os.path.isfile(new_user):

            alc.open_file(new_user)

        return {'FINISHED'}
Пример #5
0
    def execute(self, context):
        # my_users =  bpy.props.EnumProperty(items = split_string(self.my_string))

        path_object = get_shot_from_name(
            bpy.types.Scene.scene_enum.replace('publish', self.users))

        open_file = path_object.latest_version().copy(set_proper_filename=True,
                                                      ext='blend').path_root
        print(open_file)
        message = 'selected {}'.format(open_file)

        alc.open_file(open_file)
        self.report({'INFO'}, message)

        return {'FINISHED'}
Пример #6
0
    def execute(self, context):
        self.report({'INFO'}, "Selected: %s" % self.selected_variant)
        new_user = alc.scene_object().copy(variant=self.selected_variant,
                                           latest=True)
        import os
        if os.path.isfile(new_user.path_root):
            open_file = new_user.path_root

        else:
            for i in new_user.glob_project_element('user'):
                path = new_user.copy(user=i).path_root
                if os.path.isfile(path):
                    open_file = path

        alc.open_file(open_file)
        return {'FINISHED'}
Пример #7
0
def switch_context():
    import os

    scene = alc.scene_object()

    if scene.context == 'source':

        newpath = scene.copy(context='render')

    else:
        newpath = scene.copy(context='source')

    if os.path.isdir(newpath.copy(filename='').path_root):

        alc.open_file(newpath.path_root)

    else:
        alc.confirm_prompt(message='ERROR no such directory')
Пример #8
0
def run():
    """
    This run statement is what's executed when your button is pressed in blender.
    :return:
    """

    from os.path import exists, basename
    from cgl.plugins.blender import alchemy as alc
    fp = bpy.utils.user_resource('CONFIG', "recent-files.txt")
    print(fp)

    try:
        with open(fp) as file:
            recent_files = file.read().splitlines()
    except (IOError, OSError, FileNotFoundError):
        recent_files = []

    alc.open_file(recent_files[0])
Пример #9
0
def open_available_file(path_object):
    import os
    filename = alc.PathObject(path_object).copy(filename='')
    print(filename.path_root)
    found = False
    files = os.listdir(filename.path_root)

    print(files)
    if files:
        for file in files:
            if file.endswith('.blend') and not found:
                found = True
                print(path_object)
                new_file = filename.copy(filename=file).path_root
                os.rename(new_file, path_object)
                alc.open_file(path_object)

    else:
        alc.confirm_prompt(message='No file found')
Пример #10
0
    def execute(self, context):
        self.report({'INFO'}, "Selected: %s" % self.selected_task)
        new_user = alc.scene_object().copy(
            task=self.selected_task,
            set_proper_filename=True).latest_version().path_root
        if os.path.isfile(new_user):
            alc.open_file(new_user)

        else:
            new_user = alc.scene_object().copy(
                task=self.selected_task,
                user='******',
                set_proper_filename=True).latest_version().path_root
            if os.path.isfile(new_user):
                alc.open_file(new_user)
            else:

                alc.confirm_prompt(
                    message='file des not exist, please check manually  ')

        return {'FINISHED'}
Пример #11
0
    def run(self):
        """
        script to be executed when the preflight is run.

        If the preflight is successful:
        self.pass_check('Message about a passed Check')

        if the preflight fails:
        self.fail_check('Message about a failed check')
        :return:
        """
        print('Publish')

        # alc.save_file()
        current_scene = alc.scene_object()
        render_file = current_scene.copy(context='render')
        current_source = current_scene.copy(context='source',
                                            filename=None,
                                            ext=None).path_root
        current_render = current_scene.copy(context='render',
                                            filename=None,
                                            ext=None).path_root

        bpy.ops.file.make_paths_relative()
        if os.path.isdir(current_render):
            if current_scene.filename not in os.listdir(current_render):
                alc.save_file_as(render_file.path_root)
            else:
                os.remove(render_file.path_root)
                alc.save_file_as(render_file.path_root)
        else:
            os.makedirs(current_render)
            alc.save_file_as(render_file.path_root)

        alc.open_file(current_scene.copy(context='source').path_root)
        bpy.ops.file.make_paths_relative()
        alc.save_file()
        bpy.ops.object.copy_latest_low()
        self.pass_check('Check Passed')
        self.final_check()
Пример #12
0
 def execute(self, context):
     self.report({'INFO'}, "Selected: %s" % self.selected_users)
     new_user = alc.scene_object().copy(
         user=self.selected_users).latest_version().path_root
     alc.open_file(new_user)
     return {'FINISHED'}
Пример #13
0
 def execute(self, context):
     self.report({'INFO'}, "Selected: %s" % self.selected_resolution)
     resolution = alc.scene_object().copy(
         resolution=self.selected_resolution).path_root
     alc.open_file(resolution)
     return {'FINISHED'}
Пример #14
0
 def execute(self, context):
     self.report({'INFO'}, "Selected: %s" % self.my_enum)
     alc.open_file(get_asset_from_name(self.my_enum).path_root)
     return {'FINISHED'}