diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index ca88b9b63c..1c64d22733 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -2043,7 +2043,8 @@ def create( variant, folder_entity=None, task_entity=None, - pre_create_data=None + pre_create_data=None, + active=None ): """Trigger create of plugins with standartized arguments. @@ -2061,6 +2062,8 @@ def create( of creation (possible context of created instance/s). task_entity (Dict[str, Any]): Task entity. pre_create_data (Dict[str, Any]): Pre-create attribute values. + active (Optional[bool]): Whether the created instance defaults + to be active or not. Returns: Any: Output of triggered creator's 'create' method. @@ -2126,6 +2129,14 @@ def create( "productType": creator.product_type, "variant": variant } + if active is not None: + if not isinstance(active, bool): + self.log.warning( + "CreateContext.create 'active' argument is not a bool. " + f"Converting {active} {type(active)} to bool.") + active = bool(active) + instance_data["active"] = active + return creator.create( product_name, instance_data, diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 33413b465b..7b15dff049 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -1794,6 +1794,16 @@ def get_create_plugin_options(self, options=None): "\ncompiling of product name." ) ), + attribute_definitions.BoolDef( + "active", + label="Active", + default=options.get("active", True), + tooltip=( + "Active" + "\nDefines whether the created instance will default to " + "active or not." + ) + ), attribute_definitions.UISeparatorDef(), attribute_definitions.NumberDef( "order", @@ -1823,6 +1833,7 @@ def populate_create_placeholder(self, placeholder, pre_create_data=None): legacy_create = self.builder.use_legacy_creators creator_name = placeholder.data["creator"] create_variant = placeholder.data["create_variant"] + active = placeholder.data.get("active") creator_plugin = self.builder.get_creators_by_name()[creator_name] @@ -1870,7 +1881,8 @@ def populate_create_placeholder(self, placeholder, pre_create_data=None): create_variant, folder_entity, task_entity, - pre_create_data=pre_create_data + pre_create_data=pre_create_data, + active=active ) except: # noqa: E722