__init__.py 1.1 KB
Newer Older
R
repsac 已提交
1 2
import os
import bpy
3
from . import object as object_, mesh, material, camera, light
R
repsac 已提交
4 5 6 7
from .. import logger


def active_object():
8 9 10 11 12
    """

    :return: The actively selected object

    """
R
repsac 已提交
13 14 15 16
    return bpy.context.scene.objects.active


def init():
17 18 19 20 21
    """Initializing the api module. Required first step before
    initializing the actual export process.
    """
    logger.debug("Initializing API")
    object_.clear_mesh_map()
R
repsac 已提交
22 23 24


def selected_objects(valid_types=None):
25 26 27 28 29 30
    """Selected objects.

    :param valid_types: Filter for valid types (Default value = None)

    """
    logger.debug("api.selected_objects(%s)", valid_types)
R
repsac 已提交
31 32 33 34 35 36 37 38
    for node in bpy.context.selected_objects:
        if valid_types is None:
            yield node.name
        elif valid_types is not None and node.type in valid_types:
            yield node.name


def set_active_object(obj):
39 40 41 42 43 44
    """Set the object as active in the scene

    :param obj:

    """
    logger.debug("api.set_active_object(%s)", obj)
R
repsac 已提交
45 46 47 48
    bpy.context.scene.objects.active = obj


def scene_name():
49 50 51 52 53
    """

    :return: name of the current scene

    """
R
repsac 已提交
54 55
    return os.path.basename(bpy.data.filepath)