fix for all propgroups other than tuple, that already worked

This commit is contained in:
DasLixou 2024-08-20 18:08:53 +02:00
parent 0e62da4d19
commit 7f4c8d34f3
4 changed files with 39 additions and 16 deletions

View File

@ -3,6 +3,7 @@ from .utils import generate_wrapper_propertyGroup
from . import process_component
def process_list(registry, definition, update, nesting_long_names=[]):
blender_property_mapping = registry.blender_property_mapping
value_types_defaults = registry.value_types_defaults
type_infos = registry.type_infos
@ -13,7 +14,7 @@ def process_list(registry, definition, update, nesting_long_names=[]):
item_definition = type_infos[ref_name]
item_long_name = item_definition["long_name"]
is_item_value_type = item_long_name in value_types_defaults
is_item_value_type = item_long_name in blender_property_mapping
property_group_class = None
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !

View File

@ -3,6 +3,7 @@ from .utils import generate_wrapper_propertyGroup
from . import process_component
def process_map(registry, definition, update, nesting_long_names=[]):
blender_property_mapping = registry.blender_property_mapping
value_types_defaults = registry.value_types_defaults
type_infos = registry.type_infos
@ -19,7 +20,7 @@ def process_map(registry, definition, update, nesting_long_names=[]):
if key_ref_name in type_infos:
key_definition = type_infos[key_ref_name]
original_long_name = key_definition["long_name"]
is_key_value_type = original_long_name in value_types_defaults
is_key_value_type = original_long_name in blender_property_mapping
definition_link = definition["keyType"]["type"]["$ref"]
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !
@ -38,7 +39,7 @@ def process_map(registry, definition, update, nesting_long_names=[]):
if value_ref_name in type_infos:
value_definition = type_infos[value_ref_name]
original_long_name = value_definition["long_name"]
is_value_value_type = original_long_name in value_types_defaults
is_value_value_type = original_long_name in blender_property_mapping
definition_link = definition["valueType"]["type"]["$ref"]
#if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName !

View File

@ -17,12 +17,15 @@ def process_structs(registry, definition, properties, update, nesting_long_names
if ref_name in type_infos:
original = type_infos[ref_name]
original_long_name = original["long_name"]
is_value_type = original_long_name in value_types_defaults
value = value_types_defaults[original_long_name] if is_value_type else None
is_value_type = original_long_name in blender_property_mapping
has_default_value = original_long_name in value_types_defaults
value = value_types_defaults[original_long_name] if has_default_value else None
default_values[property_name] = value
if is_value_type:
if original_long_name in blender_property_mapping:
if has_default_value:
blender_property_def = blender_property_mapping[original_long_name]
blender_property = blender_property_def["type"](
**blender_property_def["presets"],# we inject presets first
@ -31,6 +34,14 @@ def process_structs(registry, definition, properties, update, nesting_long_names
update = update
)
__annotations__[property_name] = blender_property
else:
blender_property_def = blender_property_mapping[original_long_name]
blender_property = blender_property_def["type"](
**blender_property_def["presets"],# we inject presets first
name = property_name,
update = update
)
__annotations__[property_name] = blender_property
else:
original_long_name = original["long_name"]
(sub_component_group, _) = process_component.process_component(registry, original, update, {"nested": True, "long_name": original_long_name}, nesting_long_names+[property_name])

View File

@ -11,7 +11,9 @@ from bpy_types import PropertyGroup
def generate_wrapper_propertyGroup(wrapped_type_long_name, item_long_name, definition_link, registry, update, nesting_long_names=[]):
value_types_defaults = registry.value_types_defaults
blender_property_mapping = registry.blender_property_mapping
is_item_value_type = item_long_name in value_types_defaults
is_item_value_type = item_long_name in blender_property_mapping
has_item_default_value = item_long_name in value_types_defaults
wrapper_name = "wrapper_" + wrapped_type_long_name
@ -42,8 +44,9 @@ def generate_wrapper_propertyGroup(wrapped_type_long_name, item_long_name, defin
blender_property = StringProperty(default="", update=update)
if item_long_name in blender_property_mapping:
value = value_types_defaults[item_long_name] if is_item_value_type else None
if is_item_value_type:
value = value_types_defaults[item_long_name] if has_item_default_value else None
if has_item_default_value:
blender_property_def = blender_property_mapping[item_long_name]
blender_property = blender_property_def["type"](
**blender_property_def["presets"],# we inject presets first
@ -51,6 +54,13 @@ def generate_wrapper_propertyGroup(wrapped_type_long_name, item_long_name, defin
default = value,
update = update
)
else:
blender_property_def = blender_property_mapping[item_long_name]
blender_property = blender_property_def["type"](
**blender_property_def["presets"],# we inject presets first
name = "property_name",
update = update
)
wrapper_annotations = {
'0' : blender_property