Map RNA float array properties to mathutils types using subtype

RNA properties with subtypes like TRANSLATION, XYZ, EULER, QUATERNION,
COLOR, MATRIX are now mapped to the corresponding mathutils types
(Vector, Euler, Quaternion, Color, Matrix) instead of list[float].

Also:
- Add gpu.types override for 5.1 (uniform_float accepts mathutils types)
- Fix README snippet to use assert for active_object None check

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-31 17:32:24 +02:00
co-authored by Claude Opus 4.6
parent 9484e364c2
commit 35a370a412
4 changed files with 26 additions and 4 deletions
+15
View File
@@ -2138,6 +2138,21 @@ def rna_property_to_type(prop: object) -> str:
if array_length == 0 and is_array:
# Dynamic-length array — at runtime this is a bpy_prop_array
return f"bpy_prop_array[{base}]"
# Fixed-length float arrays with vector/matrix subtypes are mathutils types
subtype: str = getattr(prop, "subtype", "NONE")
if prop_type == "float" and subtype in (
"TRANSLATION", "DIRECTION", "VELOCITY", "ACCELERATION",
"XYZ", "XYZ_LENGTH",
):
return "mathutils.Vector"
if prop_type == "float" and subtype == "EULER":
return "mathutils.Euler"
if prop_type == "float" and subtype == "QUATERNION":
return "mathutils.Quaternion"
if prop_type == "float" and subtype in ("COLOR", "COLOR_GAMMA") and array_length == 3:
return "mathutils.Color"
if prop_type == "float" and subtype == "MATRIX":
return "mathutils.Matrix"
return f"list[{base}]"
return RNA_TYPE_MAP.get(prop_type, prop_type)