Scene Manager: Load Publish and numbered instances
Load Publish (Loaded panel) searches every asset of the project, then loads any of its published .blend files at any version, cast in the shot or not. The file the casting would load and the latest version on this site are preselected; a version not on this site is requested instead. Built on the existing wtd_list_assets / wtd_get_asset_files / wtd_get_revisions commands. New instances are numbered (COL_bob_01, tree_01...), counting on from the highest number in the file (SCENE_MANAGER_INSTANCE_NAME). README: Pick Shot only lists shots that exist in Libreflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6ec2b228ae
commit
fbc7ac18e4
9 files changed
+307
-32
No files matched your search
@@ -163,8 +163,10 @@ def add_instance(scene, view_layer, library, parent=None):
|
||||
scene.collection.children.unlink(instance)
|
||||
if parent.children.get(instance.name) != instance:
|
||||
parent.children.link(instance)
|
||||
instance.name = numbered_name(collection.name, bpy.data.collections)
|
||||
else:
|
||||
instance = bpy.data.objects.new(library.get("wtd_asset_name", collection.name), None)
|
||||
name = numbered_name(library.get("wtd_asset_name", collection.name), bpy.data.objects)
|
||||
instance = bpy.data.objects.new(name, None)
|
||||
instance.instance_type = "COLLECTION"
|
||||
instance.instance_collection = collection
|
||||
parent.objects.link(instance)
|
||||
@@ -172,6 +174,17 @@ def add_instance(scene, view_layer, library, parent=None):
|
||||
return instance
|
||||
|
||||
|
||||
def numbered_name(base, ids):
|
||||
"""config SCENE_MANAGER_INSTANCE_NAME for the number after the highest one ``ids`` use
|
||||
(bob_01, bob_02...; removing bob_01 does not free its number while bob_02 exists)."""
|
||||
template = config.SCENE_MANAGER_INSTANCE_NAME
|
||||
before, _, rest = template.partition("{number")
|
||||
after = rest.partition("}")[2]
|
||||
pattern = re.compile(re.escape(before.format(name=base)) + r"(\d+)" + re.escape(after.format(name=base)) + "$")
|
||||
numbers = [int(match.group(1)) for id in ids if (match := pattern.match(id.name))]
|
||||
return template.format(name=base, number=max(numbers, default=0) + 1)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Levels of detail
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
Reference in new issue
Block a user