示例#1
0
    def execute(self, context):
        self.report({'INFO'}, "Selected: %s" % self.selected_task)

        if self.selected_task == 'Base Mesh':
            new_task = alc.scene_object().copy(
                context='render',
                task='mdl',
                type='lib',
                asset='baseMesh',
                user='******',
                set_proper_filename=True).latest_version().path_root
        else:

            new_task = alc.scene_object().copy(
                context='render',
                task=self.selected_task,
                user='******',
                set_proper_filename=True).latest_version().path_root
        if os.path.isfile(new_task):

            print(new_task)
            alc.import_file(new_task, linked=True, append=False)

        else:
            alc.confirm_prompt(
                message=
                'publish not found, please check if the task has been published or import manually  '
            )

        return {'FINISHED'}
示例#2
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))
        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)

        message = 'selected {}'.format(open_file.path_root)

        alc.import_file(filepath=open_file.path_root,
                        collection_name=path_object.filename_base,
                        linked=False,
                        append=False,
                        type='COLLECTION')
        bpy.context.scene.collection.children.link(
            bpy.data.collections[path_object.filename_base])
        self.report({'INFO'}, message)

        return {'FINISHED'}
def read_materials(path_object=None):
    """

    :type path_object: object
    """
    from cgl.plugins.blender import alchemy as alc
    from cgl.core.utils.read_write import load_json
    """
    Reads the materials on the shdr task from defined from a json file
    :return:
    """
    import bpy
    if path_object is None:
        path_object = alc.scene_object()

    shaders = path_object.copy(task='shd',
                               user='******',
                               set_proper_filename=True).latest_version()
    outFile = shaders.copy(ext='json').path_root

    data = load_json(outFile)

    for obj in data.keys():
        object = bpy.data.objects[obj]
        # data = object.data
        index = 0

        for material in data[obj].keys():

            if material not in bpy.data.materials:
                alc.import_file(shaders.path_root,
                                collection_name=material,
                                type='MATERIAL',
                                linked=False)

            if material not in object.data.materials:
                object.data.materials.append(bpy.data.materials[material])

            face_list = data[obj][material]

            for face in face_list:
                object.data.polygons[face].select = True

            bpy.ops.object.mode_set(mode='EDIT')
            bpy.context.tool_settings.mesh_select_mode = [False, False, True]
            object.active_material_index = index
            bpy.ops.object.material_slot_assign()
            bpy.ops.mesh.select_all(action='DESELECT')
            bpy.ops.object.mode_set(mode='OBJECT')
            index += 1
示例#4
0
def get_default_camera():
    current_scene = alc.scene_object()
    dict_ = {
        'company': current_scene.company,
        'context': 'source',
        'project': current_scene.project,
        'scope': 'shots',
        'seq': 'DEFAULT_RIG_CHECK',
        'shot': '0010',
        'task': 'cam',
        'user': '******',
        'resolution': 'high'
    }

    path_object = alc.PathObject(dict_)
    path_object.set_attr(
        filename='%s_%s_%s.%s' %
        (path_object.seq, path_object.shot, path_object.task, 'blend'))
    default_camera = path_object.latest_version()
    print(default_camera.path_root)

    default_in_scene = False
    for group in bpy.data.node_groups:
        if path_object.filename in group.name:
            default_in_scene = True

    if not default_in_scene:
        alc.import_file(filepath=default_camera.path_root,
                        type='CAMERA',
                        linked=False,
                        collection_name=path_object.filename_base)
        bpy.context.scene.collection.objects.link(
            bpy.data.objects[path_object.filename_base])

    outFile = default_camera.copy(ext='json').path_root
    with open(outFile) as json_file:

        data = json.load(json_file)
        bpy.context.scene.frame_start = data['frame_start']
        bpy.context.scene.frame_end = data['frame_end']

    #

    return (default_camera)
示例#5
0
def run():
    """
    This run statement is what's executed when your button is pressed in blender.
    :return:
    """
    baseMesh = alc.scene_object().copy(asset='baseMesh', task='mdl', user='******', latest=True,
                                      set_proper_filename=True, type='lib')
    print(baseMesh.path_root)

    alc.import_file(baseMesh.path_root)

    bpy.ops.object.make_local(type='ALL')

    base_mesh = bpy.data.objects['baseMesh']
    base_mesh.select_set(True)

    bpy.ops.object.duplicates_make_real()

    bpy.ops.object.select_all(action='DESELECT')
    base_mesh.select_set(True)

    bpy.ops.object.delete(use_global=False)
def get_default_lighting():
    current_scene = alc.scene_object()
    dict_ = {
        'company': current_scene.company,
        'context': 'source',
        'project': current_scene.project,
        'scope': 'shots',
        'seq': 'DEFAULT_LIGHT_SETUP',
        'shot': '0010',
        'task': 'light',
        'user': '******',
        'resolution': 'high'
    }

    path_object = alc.PathObject(dict_)
    path_object.set_attr(filename='%s_%s_%s.%s' %
                         (path_object.seq, path_object.shot, path_object.task,
                          current_scene.ext))
    default_light = path_object.latest_version()
    print(default_light.path_root)

    default_in_scene = False
    for collection in bpy.data.collections:
        if 'defautLightSet' in collection.name:
            default_in_scene = True

    if not default_in_scene:
        alc.import_file(
            filepath=default_light.path_root,
            collection_name=default_light.filename_base,
            linked=False,
            append=False,
            type='COLLECTION',
        )

    bpy.context.scene.collection.children.link(
        bpy.data.collections[path_object.shot])
    return (default_light)