finish refacto, now testing and fixing bug
This commit is contained in:
+25
-13
@@ -794,6 +794,7 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
frame_start: IntProperty(name="Frame Start")
|
||||
frame_end: IntProperty(name="Frame End")
|
||||
tags: StringProperty(name='Tags', description='Tags need to separate with a comma (,)')
|
||||
description: StringProperty(name='Description')
|
||||
|
||||
#library: EnumProperty(items=lambda s, c: s.library_items, name="Library")
|
||||
#library: EnumProperty(items=lambda s, c: LIBRARY_ITEMS, name="Library")
|
||||
@@ -828,6 +829,7 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.separator()
|
||||
prefs = get_addon_prefs()
|
||||
|
||||
#row = layout.row(align=True)
|
||||
layout.use_property_split = True
|
||||
@@ -850,6 +852,8 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
#layout.separator()
|
||||
#self.draw_tags(self.asset_action, layout)
|
||||
layout.prop(self, 'tags')
|
||||
layout.prop(self, 'description', text='Description')
|
||||
#layout.prop(prefs, 'author', text='Author')
|
||||
|
||||
#layout.prop()
|
||||
|
||||
@@ -889,7 +893,7 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
#self.sce
|
||||
|
||||
#lib = self.current_library
|
||||
self.tags = os.getlogin()
|
||||
self.tags = ''
|
||||
|
||||
|
||||
#print(self, self.library_items)
|
||||
@@ -901,6 +905,7 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
|
||||
def action_to_asset(self, action):
|
||||
#action.asset_mark()
|
||||
prefs = get_addon_prefs()
|
||||
action.name = self.name
|
||||
action.asset_generate_preview()
|
||||
|
||||
@@ -930,6 +935,10 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
|
||||
action.asset_data['is_single_frame'] = is_single_frame
|
||||
action.asset_data['rig'] = bpy.context.object.name
|
||||
|
||||
action.asset_data.description = self.description
|
||||
action.asset_data.author = prefs.author
|
||||
|
||||
col = get_overriden_col(bpy.context.object)
|
||||
if col:
|
||||
action.asset_data['col'] = col.name
|
||||
@@ -1003,10 +1012,10 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
lib = prefs.libraries[self.current_library.store_library]
|
||||
|
||||
#lib_path = lib.library_path
|
||||
name = lib.adapter.norm_file_name(self.name)
|
||||
asset_path = lib.adapter.get_asset_path(name=name, catalog=self.catalog)
|
||||
img_path = lib.adapter.get_path('image', name, asset_path)
|
||||
video_path = lib.adapter.get_path('video', name, asset_path)
|
||||
#name = lib.adapter.norm_file_name(self.name)
|
||||
asset_path = lib.adapter.get_asset_path(name=self.name, catalog=self.catalog)
|
||||
img_path = lib.adapter.get_image_path(name=self.name, catalog=self.catalog, filepath=asset_path)
|
||||
video_path = lib.adapter.get_video_path(name=self.name, catalog=self.catalog, filepath=asset_path)
|
||||
|
||||
## Copy Action
|
||||
current_action = ob.animation_data.action
|
||||
@@ -1027,13 +1036,16 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
|
||||
lib.adapter.write_asset(asset=asset_action, asset_path=asset_path)
|
||||
|
||||
asset_description = lib.adapter.get_asset_description(
|
||||
asset=asset_action,
|
||||
catalog=self.catalog,
|
||||
modified=time.time_ns()
|
||||
)
|
||||
|
||||
lib.adapter.write_description_file(asset_description, asset_path)
|
||||
# asset_description = lib.adapter.get_asset_description(dict(
|
||||
# author=prefs.author,
|
||||
# assets=[dict(
|
||||
# name=asset_action.name,
|
||||
# description=self.description,
|
||||
# catalog=self.catalog,
|
||||
# tags=self.tags.split(',')
|
||||
# )]), asset_path
|
||||
# )
|
||||
# lib.adapter.write_description_file(asset_description, asset_path)
|
||||
|
||||
# Restore action and cleanup
|
||||
ob.animation_data.action = current_action
|
||||
@@ -1045,7 +1057,7 @@ class ACTIONLIB_OT_store_anim_pose(Operator):
|
||||
# TODO Write a proper method for this
|
||||
diff_path = Path(bpy.app.tempdir, 'diff.json')
|
||||
|
||||
diff = [dict(a, operation='ADD') for a in lib.adapter.norm_asset_datas([asset_description])]
|
||||
diff = [dict(a, operation='ADD') for a in lib.adapter.norm_cache([asset_description])]
|
||||
diff_path.write_text(json.dumps(diff, indent=4))
|
||||
|
||||
bpy.ops.assetlib.bundle(name=lib.name, diff=str(diff_path), blocking=True)
|
||||
|
||||
Reference in New Issue
Block a user