Blender Kitsu: New Assset Tagging System #286
@ -26,6 +26,7 @@ import bpy
|
|||||||
from .. import bkglobals, cache, util, prefs
|
from .. import bkglobals, cache, util, prefs
|
||||||
from ..logger import LoggerFactory
|
from ..logger import LoggerFactory
|
||||||
from ..types import TaskType, AssetType
|
from ..types import TaskType, AssetType
|
||||||
|
from ..context import core as context_core
|
||||||
|
|
||||||
logger = LoggerFactory.getLogger()
|
logger = LoggerFactory.getLogger()
|
||||||
|
|
||||||
@ -240,11 +241,57 @@ class KITSU_OT_con_detect_context(bpy.types.Operator):
|
|||||||
return mapping[key]
|
return mapping[key]
|
||||||
|
|
||||||
|
|
||||||
|
class KITSU_OT_con_set_asset(bpy.types.Operator):
|
||||||
|
bl_idname = "kitsu.con_set_asset"
|
||||||
|
bl_label = "Set Kitsu Asset"
|
||||||
|
bl_description = (
|
||||||
|
"Mark the current file & target collection as an Asset on Kitsu Server "
|
||||||
|
"Assets marked with this method will be automatically loaded by the "
|
||||||
|
"Shot Builder, if the Asset is casted to the buider's target shot"
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
kitsu_props = context.scene.kitsu
|
||||||
|
if bpy.data.filepath == "":
|
||||||
|
cls.poll_message_set("Blend file must be saved")
|
||||||
|
return False
|
||||||
|
if not context_core.is_asset_context():
|
||||||
|
cls.poll_message_set("Kitsu Context panel must be set to 'Asset'")
|
||||||
|
return False
|
||||||
|
if kitsu_props.asset_type_active_name == "":
|
||||||
|
cls.poll_message_set("Asset Type must be set")
|
||||||
|
return False
|
||||||
|
if kitsu_props.asset_active_name == "":
|
||||||
|
cls.poll_message_set("Asset must be set")
|
||||||
|
return False
|
||||||
|
if not kitsu_props.asset_col:
|
||||||
|
cls.poll_message_set("Asset Collection must be set")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
blender_asset = context.scene.kitsu.asset_col
|
||||||
|
kitsu_asset = cache.asset_active_get()
|
||||||
|
if not kitsu_asset:
|
||||||
|
self.report({"ERROR"}, "Failed to find active Kitsu Asset")
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
kitsu_asset.set_asset_path(
|
||||||
|
bpy.data.filepath, blender_asset.name, blender_asset.rna_type.name
|
||||||
|
)
|
||||||
|
self.report(
|
||||||
|
{"INFO"}, f"Kitsu Asset '{kitsu_asset.name}' set to Collection '{blender_asset.name}'"
|
||||||
|
)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
# ---------REGISTER ----------.
|
# ---------REGISTER ----------.
|
||||||
|
|
||||||
classes = [
|
classes = [
|
||||||
KITSU_OT_con_productions_load,
|
KITSU_OT_con_productions_load,
|
||||||
KITSU_OT_con_detect_context,
|
KITSU_OT_con_detect_context,
|
||||||
|
KITSU_OT_con_set_asset,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,9 +22,7 @@ import bpy
|
|||||||
|
|
||||||
from ..context import core as context_core
|
from ..context import core as context_core
|
||||||
from .. import cache, prefs, ui, bkglobals
|
from .. import cache, prefs, ui, bkglobals
|
||||||
from ..context.ops import (
|
from ..context.ops import KITSU_OT_con_detect_context, KITSU_OT_con_set_asset
|
||||||
KITSU_OT_con_detect_context,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class KITSU_PT_vi3d_context(bpy.types.Panel):
|
class KITSU_PT_vi3d_context(bpy.types.Panel):
|
||||||
@ -113,6 +111,34 @@ class KITSU_PT_vi3d_context(bpy.types.Panel):
|
|||||||
context_core.draw_task_type_selector(context, col)
|
context_core.draw_task_type_selector(context, col)
|
||||||
|
|
||||||
|
|
||||||
|
class KITSU_PT_set_asset(bpy.types.Panel):
|
||||||
|
"""
|
||||||
|
Panel in 3dview that enables browsing through backend data structure.
|
||||||
|
Thought of as a menu to setup a context by selecting active production
|
||||||
|
active sequence, shot etc.
|
||||||
|
"""
|
||||||
|
|
||||||
|
bl_category = "Kitsu"
|
||||||
|
bl_label = "Set Asset"
|
||||||
|
bl_space_type = "VIEW_3D"
|
||||||
|
bl_region_type = "UI"
|
||||||
|
bl_options = {"DEFAULT_CLOSED"}
|
||||||
|
bl_order = 25
|
||||||
|
bl_parent_id = "KITSU_PT_vi3d_context"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context_core.is_asset_context()
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False
|
||||||
|
col = layout.column()
|
||||||
|
col.prop(context.scene.kitsu, "asset_col")
|
||||||
|
col.operator(KITSU_OT_con_set_asset.bl_idname)
|
||||||
|
|
||||||
|
|
||||||
class KITSU_PT_comp_context(KITSU_PT_vi3d_context):
|
class KITSU_PT_comp_context(KITSU_PT_vi3d_context):
|
||||||
bl_space_type = "NODE_EDITOR"
|
bl_space_type = "NODE_EDITOR"
|
||||||
|
|
||||||
@ -124,7 +150,12 @@ class KITSU_PT_editorial_context(KITSU_PT_vi3d_context):
|
|||||||
# ---------REGISTER ----------.
|
# ---------REGISTER ----------.
|
||||||
|
|
||||||
# Classes that inherit from another need to be registered first for some reason.
|
# Classes that inherit from another need to be registered first for some reason.
|
||||||
classes = [KITSU_PT_comp_context, KITSU_PT_editorial_context, KITSU_PT_vi3d_context]
|
classes = [
|
||||||
|
KITSU_PT_comp_context,
|
||||||
|
KITSU_PT_editorial_context,
|
||||||
|
KITSU_PT_vi3d_context,
|
||||||
|
KITSU_PT_set_asset,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
@ -279,6 +279,8 @@ class KITSU_property_group_scene(bpy.types.PropertyGroup):
|
|||||||
NOTE: It would be nice to have searchable enums instead of doing all this work manually.
|
NOTE: It would be nice to have searchable enums instead of doing all this work manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
asset_col: bpy.props.PointerProperty(type=bpy.types.Collection, name="Collection")
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Sequence
|
# Sequence
|
||||||
###########
|
###########
|
||||||
|
@ -735,6 +735,16 @@ class Asset(Entity):
|
|||||||
asset_dict = gazu.asset.get_asset(asset_id)
|
asset_dict = gazu.asset.get_asset(asset_id)
|
||||||
return cls.from_dict(asset_dict)
|
return cls.from_dict(asset_dict)
|
||||||
|
|
||||||
|
def update(self) -> Asset:
|
||||||
|
gazu.asset.update_asset_data(asdict(self))
|
||||||
|
return self
|
||||||
|
|
||||||
|
def set_asset_path(self, asset_path: str, asset_name: str, asset_type: str):
|
||||||
|
self.data["asset_path"] = asset_path
|
||||||
|
self.data["asset_name"] = asset_name
|
||||||
|
self.data["asset_type"] = asset_type
|
||||||
|
self.update()
|
||||||
|
|
||||||
def get_all_task_types(self) -> List[TaskType]:
|
def get_all_task_types(self) -> List[TaskType]:
|
||||||
return [TaskType.from_dict(t) for t in gazu.task.all_task_types_for_asset(asdict(self))]
|
return [TaskType.from_dict(t) for t in gazu.task.all_task_types_for_asset(asdict(self))]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user