예제 #1
0
    def _create_body(self, name, bodyobj):
        '''
		If a body with that name already exists, raises EnvironmentError.
		The bodyobj is the class name for the body that will be created.
		'''
        name = pipeline_io.alphanumeric(name)
        print("name: ", name)
        filepath = os.path.join(bodyobj.get_parent_dir(), name)
        print("filepath: ", filepath)

        if name in self.list_bodies():
            # raise EnvironmentError('body already exists: '+filepath)
            return None  # body already exists

        if not pipeline_io.mkdir(filepath):
            raise OSError('couldn\'t create body directory: ' + filepath)
            # some issue

        datadict = bodyobj.create_new_dict(name)
        pipeline_io.writefile(
            os.path.join(filepath, bodyobj.PIPELINE_FILENAME), datadict)
        new_body = bodyobj(filepath)
        for dept in bodyobj.default_departments():
            pipeline_io.mkdir(os.path.join(filepath, dept))
            new_body.create_element(dept, Element.DEFAULT_NAME)

        return new_body
예제 #2
0
    def delete_ribs_for_bodies(self, bodies):
        for body in bodies:
            body = self.get_body(body)
            element = body.get_element(Department.RIB_ARCHIVE)

            rib_cache_dir = element.get_cache_dir()
            try:
                # delete the rib cache dir
                shutil.rmtree(rib_cache_dir)

            except:
                # create a new cache dir
                pipeline_io.mkdir(rib_cache_dir)

        print("deleted ribs for " + str(bodies))
예제 #3
0
    def create_asset(self, name, asset_type=AssetType.PROP):
        '''
		creates a new asset with the given name, and returns the resulting asset object.
		name -- the name of the new asset to create
		'''
        asset = self._create_body(name, Asset)

        if asset is None:
            return None  # asset already exists.

        asset.update_type(asset_type)

        if asset_type == str(AssetType.SHOT):
            rendered_shots = Environment().get_shots_dir()
            dir = os.path.join(rendered_shots, name)
            pipeline_io.mkdir(dir)

        return asset