mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Fix: Swap functionality not implemented for Typed Bundle node operator
A new operator for creating bundles with a Type input was introduced in
9b81403e0d.
However, the equivalent Swap functionality was not included. This results in a
bunch of errors when calling the operator from the Swap menu. This patch
introduces the necessary functionality, via `node.swap_typed_bundle`, allowing
the user to be able to swap to typed bundle nodes.
Pull Request: https://projects.blender.org/blender/blender/pulls/158500
This commit is contained in:
parent
3c722d84f0
commit
c93198d62c
2 changed files with 23 additions and 2 deletions
|
|
@ -53,7 +53,10 @@ def cast_value(source, target):
|
|||
source_type = source.type
|
||||
target_type = target.type
|
||||
|
||||
value = source.default_value
|
||||
if hasattr(source, "default_value"):
|
||||
value = source.default_value
|
||||
else:
|
||||
return None
|
||||
|
||||
def to_bool(value):
|
||||
return value > 0
|
||||
|
|
@ -746,6 +749,21 @@ class NODE_OT_add_typed_bundle(NodeAddOperator, bpy.types.Operator):
|
|||
return {"FINISHED"}
|
||||
|
||||
|
||||
class NODE_OT_swap_typed_bundle(NodeAddOperator, bpy.types.Operator):
|
||||
bl_idname = "node.swap_typed_bundle"
|
||||
bl_label = "Swap Typed Bundle"
|
||||
bl_description = "Swap existing node with a Combine Bundle node with a type input"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.node.swap_node('INVOKE_DEFAULT', type="NodeCombineBundle")
|
||||
|
||||
for node in context.selected_nodes:
|
||||
node.bundle_items.new("STRING", "Type")
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ZoneOperator:
|
||||
offset: FloatVectorProperty(
|
||||
name="Offset",
|
||||
|
|
@ -1528,6 +1546,7 @@ classes = (
|
|||
NODE_OT_add_foreach_geometry_element_zone,
|
||||
NODE_OT_add_closure_zone,
|
||||
NODE_OT_add_typed_bundle,
|
||||
NODE_OT_swap_typed_bundle,
|
||||
NODE_OT_collapse_hide_unused_toggle,
|
||||
NODE_OT_interface_item_new,
|
||||
NODE_OT_interface_item_new_panel_toggle,
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class NodeMenu(Menu):
|
|||
|
||||
@classmethod
|
||||
def typed_bundle(cls, layout, label):
|
||||
props = layout.operator("node.add_typed_bundle", text=label, text_ctxt=i18n_contexts.default)
|
||||
props = layout.operator(cls.typed_bundle_operator_id, text=label, text_ctxt=i18n_contexts.default)
|
||||
|
||||
if hasattr(props, "use_transform"):
|
||||
props.use_transform = cls.use_transform
|
||||
|
|
@ -408,6 +408,7 @@ class AddNodeMenu(NodeMenu):
|
|||
main_operator_id = "node.add_node"
|
||||
zone_operator_id = "node.add_zone"
|
||||
new_empty_group_operator_id = "node.add_empty_group"
|
||||
typed_bundle_operator_id = "node.add_typed_bundle"
|
||||
|
||||
root_asset_menu = "NODE_MT_node_add_root_catalogs"
|
||||
|
||||
|
|
@ -424,6 +425,7 @@ class SwapNodeMenu(NodeMenu):
|
|||
main_operator_id = "node.swap_node"
|
||||
zone_operator_id = "node.swap_zone"
|
||||
new_empty_group_operator_id = "node.swap_empty_group"
|
||||
typed_bundle_operator_id = "node.swap_typed_bundle"
|
||||
|
||||
root_asset_menu = "NODE_MT_node_swap_root_catalogs"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue