-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blender: Dynamic workflow using linked libraries and overrides #3463
Blender: Dynamic workflow using linked libraries and overrides #3463
Conversation
Task linked: OP-2598 Demo generator |
56acc57
to
99c2d0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello. Thank you for your work! Here are the main points we discussed on Thursday that need some changes:
- A model loader behaves differently depending on the task it is launched from. This shouldn't happen. There should be two different loaders that execute the two alternatives.
- After loading a layout, it is not possible to update the single rigs in it.
- After loading a layout, a single animation instance is created. There should be an instance for each rig instead.
I'm wondering if we shouldn't take advantage of families for the Staging information are stored into the |
5c969a3
to
99bf5e2
Compare
5778826
to
358a6ff
Compare
dfd0f91
to
1d6aa2d
Compare
4bece85
to
a8b0812
Compare
a8b0812
to
6e603fd
Compare
@@ -612,8 +612,14 @@ def register(self, instance, repres): | |||
continue | |||
repre_context[key] = template_data[key] | |||
|
|||
# Initialize ID, trying to get it from an earlier stage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conversation related to being able predefine representation id https://github.com/pypeclub/OpenPype/discussions/3902#discussioncomment-3794454
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not needed anymore right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently developing the correct behaviour. It'll be put in new PR on this branch in some days/weeks. I'll notify you at this moment and it'll remove this change.
PR adds |
a6d13e7
to
d97752b
Compare
13413a7
to
cf46621
Compare
0dc0804
to
6ddb041
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR cannot be merged because of changes in integrator plugin which breaks publish workflow conversation here. We can't afford to add ability to define representation id before integrator plugin due to many reasons. Also the branch need update from develop branch.
We would like to have that changed so we could merge the PR.
@iLLiCiTiT I'm working on the seamless integration #3902 which includes the changes you require and a completely universal way to handle datablocks. It deeply refactors the |
Happy to hear :) |
…on_not_found Bugfix: Workfile last version not found
…dling Enhancement: UDIM resources handling
) | ||
|
||
# Filter datablocks by loader types | ||
if loader := containers_loaders.get(entity): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
|
||
from . import pipeline | ||
|
||
log = Logger.get_logger(__name__) | ||
|
||
def add_datablocks_to_container( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
wm = context.window_manager | ||
|
||
# Try to match the container referencing the current collection | ||
if matched_container := next( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
wm = context.window_manager | ||
|
||
# Try to match the container referencing the current collection | ||
if matched_container := next( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
if active_instance.name == new_instance_name: | ||
self.report( | ||
{"ERROR"}, | ||
f"Duplicate instance cannot have same name as original: {new_instance_name}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (93 > 79 characters)
if not self.use_selection: | ||
row = layout.row(align=True) | ||
|
||
creator_plugin = context.scene["openpype_creators"][self.creator_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (82 > 79 characters)
|
||
gather_into_collection: bpy.props.BoolProperty( | ||
name="Gather into collection", | ||
description="Gather outliner entities when added to instance under single collection", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (94 > 79 characters)
# Items are defaults from current creator plugin | ||
items=lambda self, context: [ | ||
(default, default, "") | ||
for default in context.scene["openpype_creators"][self.creator_name][ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
|
||
|
||
class StructDescriptor: | ||
"""Generic Descriptor to store and restor properties from blender struct.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
(Container, List of loaded datablocks) | ||
""" | ||
container = self._get_scene_container(container_metadata) | ||
assert container, f"The asset is not loaded: {container_metadata.get('objectName')}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (92 > 79 characters)
) | ||
|
||
# Filter datablocks by loader types | ||
if loader := containers_loaders.get(entity): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
|
||
from . import pipeline | ||
|
||
log = Logger.get_logger(__name__) | ||
|
||
def add_datablocks_to_container( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
wm = context.window_manager | ||
|
||
# Try to match the container referencing the current collection | ||
if matched_container := next( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
wm = context.window_manager | ||
|
||
# Try to match the container referencing the current collection | ||
if matched_container := next( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
if active_instance.name == new_instance_name: | ||
self.report( | ||
{"ERROR"}, | ||
f"Duplicate instance cannot have same name as original: {new_instance_name}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (93 > 79 characters)
if not self.use_selection: | ||
row = layout.row(align=True) | ||
|
||
creator_plugin = context.scene["openpype_creators"][self.creator_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (82 > 79 characters)
|
||
gather_into_collection: bpy.props.BoolProperty( | ||
name="Gather into collection", | ||
description="Gather outliner entities when added to instance under single collection", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (94 > 79 characters)
# Items are defaults from current creator plugin | ||
items=lambda self, context: [ | ||
(default, default, "") | ||
for default in context.scene["openpype_creators"][self.creator_name][ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
|
||
|
||
class StructDescriptor: | ||
"""Generic Descriptor to store and restor properties from blender struct.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
(Container, List of loaded datablocks) | ||
""" | ||
container = self._get_scene_container(container_metadata) | ||
assert container, f"The asset is not loaded: {container_metadata.get('objectName')}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (92 > 79 characters)
…_nodegroups Bugfix: Switch asset duplicates nodegroups.
Args: | ||
datablocks (List[bpy.types.ID], optional): Datablocks to process and append to instance. Defaults to None. | ||
gather_into_collection (bool): | ||
Process outliner gathering of elements under a single collection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
appends the datablocks to it. | ||
|
||
Args: | ||
datablocks (List[bpy.types.ID], optional): Datablocks to process and append to instance. Defaults to None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (118 > 79 characters)
|
||
@exec_process | ||
def process( | ||
self, datablocks: List[bpy.types.ID] = None, gather_into_collection = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (82 > 79 characters)
unexpected spaces around keyword / parameter equals
bpy.types.Scene.openpype_instance_active_index = bpy.props.IntProperty( | ||
name="OpenPype Instance Active Index", options={"HIDDEN"} | ||
) | ||
# Cannot store the containers in the scene, it overloads the RAM when rendering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
|
||
col.separator() | ||
|
||
col.menu("SCENE_MT_openpype_instances_context_menu", icon='DOWNARROW_HLT', text="") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (91 > 79 characters)
entity (Union[bpy.types.Collection, bpy.types.Object]): Outliner entity to get children from. | ||
|
||
Returns: | ||
Set[Union[bpy.types.Collection, bpy.types.Object]]: All outliner children. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (82 > 79 characters)
For an Object, only objects parented to the given one. | ||
|
||
Args: | ||
entity (Union[bpy.types.Collection, bpy.types.Object]): Outliner entity to get children from. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (101 > 79 characters)
from openpype.hosts.blender.api.properties import OpenpypeInstance | ||
from openpype.hosts.blender.api.utils import get_all_outliner_children | ||
|
||
def _get_camera_from_datablocks(datablocks: List[bpy.types.ID])->Union[bpy.types.Object, None]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
line too long (95 > 79 characters)
missing whitespace around operator
@@ -0,0 +1,13 @@ | |||
"""Create a setdress asset.""" | |||
import bpy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'bpy' imported but unused
|
||
avalon_info = obj[AVALON_PROPERTY] | ||
avalon_info.update({"container_name": group_name}) | ||
plugin.link_to_collection(objects, asset_group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'asset_group'
'action': action, | ||
'create_animation': True if family == 'rig' else False, | ||
'animation_asset': asset | ||
"parent": asset_group, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'asset_group'
* Fix: Synced representations before paths remapping * cleaning code
|
||
import bpy | ||
from openpype.hosts.blender.api.properties import OpenpypeContainer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'openpype.hosts.blender.api.properties.OpenpypeContainer' imported but unused
@@ -1,417 +1,137 @@ | |||
"""Load a rig asset in Blender.""" | |||
|
|||
from pathlib import Path | |||
from pprint import pformat | |||
from typing import Dict, List, Optional | |||
from typing import List, Tuple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'typing.List' imported but unused
'typing.Tuple' imported but unused
"""Get images used by the datablocks. | ||
|
||
Args: | ||
datablocks (Set[bpy.types.ID], optional): Datablocks to get images from. Defaults to None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (102 > 79 characters)
|
||
try: | ||
bpy.ops.file.make_paths_relative() | ||
except BaseException as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local variable 'e' is assigned to but never used
* Fix: Switch transfer custom properties * format line too long
label = "Extract workfile" | ||
hosts = ["blender"] | ||
families = ["workfile"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
result = future.result().decode() | ||
|
||
# Iterate through matched errors | ||
if errors_stack := list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
invalid = self.get_invalid(instance) | ||
if invalid: | ||
raise RuntimeError( | ||
f"Objects found with special characters in their name: {invalid}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
invalid_chars.remove(".") | ||
for obj in instance: | ||
# any is faster than regex to get char in obj.name and return bool | ||
if obj is not None and any(char in invalid_chars for char in obj.name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
invalid = [] | ||
|
||
# Set of special characters except "_" and "." which is used in naming | ||
invalid_chars = set(string.punctuation.replace("_","")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
@@ -0,0 +1,40 @@ | |||
from typing import List | |||
|
|||
import bpy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'bpy' imported but unused
str(Path(datablock.filepath).resolve()), | ||
start=str(Path(bpy.data.filepath).parent.resolve()), | ||
) | ||
except BaseException as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local variable 'e' is assigned to but never used
import bpy | ||
|
||
from openpype.hosts.blender.api.utils import get_datablocks_with_filepath | ||
from openpype.client.entities import get_representations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'openpype.client.entities.get_representations' imported but unused
required=True, | ||
) | ||
args, unknown = parser.parse_known_args( | ||
sys.argv[sys.argv.index("--") + 1 :] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace before ':'
* Refactor: Loader API for blend files * load and replace datablocks base funcs moved to utils.py * restore files for non blend loaders * rename datapath to datacol * fix class inheriting * fix rebase conflict * clean code * cleaning changes * rename to load_library_as_container, without '_' as not private function * Update openpype/hosts/blender/api/utils.py Co-authored-by: Sharkitty <81646000+Sharkitty@users.noreply.github.com> --------- Co-authored-by: Kaa Maurice <kaalium@gmail.com> Co-authored-by: Sharkitty <81646000+Sharkitty@users.noreply.github.com>
if hasattr(old_datablock, "pose") and old_datablock.pose: | ||
for bone in old_datablock.pose.bones: | ||
if new_datablock.pose: | ||
if new_bone := new_datablock.pose.bones.get(bone.name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
old_datablocks, key=lambda d: 1 if d.library else 0 | ||
): | ||
# Match new datablock by name | ||
if new_datablock := next( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
for outliner_datablock in get_root_datablocks( | ||
old_datablocks, BL_OUTLINER_TYPES | ||
): | ||
if parent_collection := get_parent_collection(outliner_datablock): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
multiple statements on one line (colon)
whitespace before ':'
Fix: Change get_task_by_name into get_task_by_entity
@kaamaurice we're closing this PR as it is now stale. If there is any functionality from this you'd like to contribute again, feel free to re-open this again, targeting AYON |
Brief description
Description
Change Blender plugins to work with a collection instead of an empty to store custom properties of the Avalon instance.
Discussion : https://github.com/pypeclub/OpenPype/discussions/2598
Based on the work of jojoba106
Blender: Dynamic workflow for Modeling > Rigging > Layout > Animation using linked libraries #2771
Squashed and rebase from : Enhancement/op 2598 blender dynamic workflow using linked lib #3171
Resolve #2890