Asset Pipeline v2 #145
44
scripts-blender/addons/asset_pipeline_2/__init__.py
Normal file
44
scripts-blender/addons/asset_pipeline_2/__init__.py
Normal file
@ -0,0 +1,44 @@
|
||||
import importlib
|
||||
|
||||
from . import ui, ops, props
|
||||
|
||||
bl_info = {
|
||||
"name": "Asset Pipeline 2",
|
||||
"author": "Nick Alberelli",
|
||||
"description": "Blender Studio Asset Pipeline Add-on",
|
||||
"blender": (3, 1, 0),
|
||||
"version": (0, 1, 2),
|
||||
"location": "View3D",
|
||||
"warning": "",
|
||||
"doc_url": "",
|
||||
"tracker_url": "",
|
||||
"category": "Generic",
|
||||
}
|
||||
|
||||
|
||||
def reload() -> None:
|
||||
global ui
|
||||
global ops
|
||||
global props
|
||||
importlib.reload(ui)
|
||||
importlib.reload(ops)
|
||||
importlib.reload(props)
|
||||
|
||||
|
||||
_need_reload = "ui" in locals()
|
||||
if _need_reload:
|
||||
reload()
|
||||
|
||||
# ----------------REGISTER--------------.
|
||||
|
||||
|
||||
def register() -> None:
|
||||
ui.register()
|
||||
ops.register()
|
||||
props.register()
|
||||
|
||||
|
||||
def unregister() -> None:
|
||||
ui.unregister()
|
||||
ops.unregister()
|
||||
props.unregister()
|
58
scripts-blender/addons/asset_pipeline_2/ops.py
Normal file
58
scripts-blender/addons/asset_pipeline_2/ops.py
Normal file
@ -0,0 +1,58 @@
|
||||
import bpy
|
||||
|
||||
|
||||
class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.update_ownership"
|
||||
bl_label = 'Update Ownership'
|
||||
|
||||
def execute(self, context):
|
||||
obj = context.active_object
|
||||
ownership = context.active_object.asset_ownership
|
||||
task_layer_name = obj.name.split(".")[-1]
|
||||
for vertex_group in obj.vertex_groups:
|
||||
if not vertex_group.name in [item.name for item in ownership]:
|
||||
item = ownership.add()
|
||||
item.name = vertex_group.name
|
||||
item.owner = task_layer_name.upper()
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class ASSETPIPE_OT_push_test(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.push_test"
|
||||
bl_label = 'Push to Publish'
|
||||
|
||||
def execute(self, context):
|
||||
if self.text != "test":
|
||||
self.report({'ERROR'}, "Failure")
|
||||
return {'CANCELLED'}
|
||||
self.report({'INFO'}, "Success")
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class ASSETPIPE_OT_pull_test(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.pull_test"
|
||||
bl_label = 'Pull from Publish'
|
||||
|
||||
def execute(self, context):
|
||||
if self.text != "test":
|
||||
self.report({'ERROR'}, "Failure")
|
||||
return {'CANCELLED'}
|
||||
self.report({'INFO'}, "Success")
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
classes = (
|
||||
ASSETPIPE_OT_push_test,
|
||||
ASSETPIPE_OT_pull_test,
|
||||
ASSETPIPE_OT_update_ownership,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
for i in classes:
|
||||
bpy.utils.register_class(i)
|
||||
|
||||
|
||||
def unregister():
|
||||
for i in classes:
|
||||
bpy.utils.unregister_class(i)
|
30
scripts-blender/addons/asset_pipeline_2/props.py
Normal file
30
scripts-blender/addons/asset_pipeline_2/props.py
Normal file
@ -0,0 +1,30 @@
|
||||
import bpy
|
||||
|
||||
|
||||
""" NOTE Items in these properties groups should be generated by a function that finds the
|
||||
avaliable task layers from the task_layer_defaults.json file that needs to be created.
|
||||
"""
|
||||
|
||||
|
||||
# items=[("MODEL", "Rigging", ""), ("RIG", "Modeling", "")],
|
||||
class ASSETOWNERSHIP(bpy.types.PropertyGroup):
|
||||
owner: bpy.props.StringProperty(name="ID Owner", default="")
|
||||
|
||||
|
||||
classes = (ASSETOWNERSHIP,)
|
||||
|
||||
|
||||
def register():
|
||||
for i in classes:
|
||||
bpy.utils.register_class(i)
|
||||
bpy.types.Object.asset_ownership = bpy.props.CollectionProperty(type=ASSETOWNERSHIP)
|
||||
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
|
||||
name="ID Owner",
|
||||
items=[("NONE", "None", ""), ("MODEL", "Rigging", ""), ("RIG", "Modeling", "")],
|
||||
)
|
||||
|
||||
|
||||
def unregister():
|
||||
for i in classes:
|
||||
bpy.utils.unregister_class(i)
|
||||
del bpy.types.Object.asset_ownership
|
35
scripts-blender/addons/asset_pipeline_2/ui.py
Normal file
35
scripts-blender/addons/asset_pipeline_2/ui.py
Normal file
@ -0,0 +1,35 @@
|
||||
import bpy
|
||||
|
||||
|
||||
class ASSETPIPE_PT_TestUI(bpy.types.Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_category = 'Asset Pipe 2'
|
||||
bl_label = "Test UI"
|
||||
|
||||
def draw(self, context: bpy.types.Context) -> None:
|
||||
self.layout.label(text="Test UI")
|
||||
self.layout.operator("assetpipe.update_ownership")
|
||||
self.layout.operator("assetpipe.push_test", icon="TRIA_UP")
|
||||
self.layout.operator("assetpipe.pull_test", icon="TRIA_DOWN")
|
||||
|
||||
if not context.active_object:
|
||||
return
|
||||
obj = context.active_object
|
||||
ownership = obj.asset_ownership
|
||||
self.layout.prop(obj, "asset_id_owner")
|
||||
for my_item in ownership:
|
||||
self.layout.label(text=f"{my_item.name} : {my_item.owner}")
|
||||
|
||||
|
||||
classes = (ASSETPIPE_PT_TestUI,)
|
||||
|
||||
|
||||
def register():
|
||||
for i in classes:
|
||||
bpy.utils.register_class(i)
|
||||
|
||||
|
||||
def unregister():
|
||||
for i in classes:
|
||||
bpy.utils.unregister_class(i)
|
Loading…
Reference in New Issue
Block a user