Source code for cgl.plugins.houdini.tasks.smart_task
import logging
[docs]
class SmartTask(object):
"""
This is a template for a "task" within the cookbook. It covers common areas when dealing with digital assets
specific to different tasks.
"""
def __init__(self, path_object=None):
"""
Args:
path_object: must be a "PathObject"
"""
from cgl.plugins.blender.alchemy import scene_object
from cgl.core.path.object import PathObject
if not path_object:
self.path_object = scene_object()
else:
self.path_object = path_object
if not isinstance(path_object, PathObject):
logging.info("{} is not instance PathObject")
return
logging.info(path_object.get_path())
# check if it's a PathObject instance
[docs]
def build(self):
"""
the tasks code associated with this task.
"""
pass
def _import(self, file_path, reference=False, **kwargs):
"""
Imports the file into the scene - this function should be smart enough to handle various file types
as well as
Returns:
if reference is True, it will return the reference node, otherwise it will return the imported node.
"""
if not file_path:
file_path = self.path_object.get_path()
from cgl.plugins.blender.alchemy import import_file, reference_file, PathObject
path_object = PathObject().from_path_string(file_path)
if reference:
return reference_file(filepath=file_path, namespace=path_object.asset)
else:
return import_file(filepath=file_path, namespace=path_object.asset)
[docs]
def import_latest(self, task=None, reference=False, **kwargs):
if not task:
task = self.path_object.task
new_obj = self.path_object.copy(
task=task,
entity_type="render",
user="publish",
latest=True,
set_filename=True,
)
import_obj = self._import(new_obj.get_path(), reference=reference)
return import_obj
[docs]
def publish(self):
"""Publishes specific to the task at hand.
By default, we just do what's in the magic_browser plugin, this allows us to customize at a more granular level
if needed.
"""
from cgl.plugins.blender.alchemy import publish
publish()
[docs]
def get_msd_data(self, task_name):
"""
creates the msd dictionary for the task being called.
"""
pass
[docs]
def render(self):
""" """
pass