diff --git a/README.md b/README.md index f177db0..2ac78dc 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ import bpy # Full autocomplete and type checking obj = bpy.context.active_object -if obj is not None: - print(obj.name) +assert obj is not None +obj.location.x = 1.0 # Collection types with proper methods bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh")) diff --git a/introspect.py b/introspect.py index bc657e2..6ae06bf 100644 --- a/introspect.py +++ b/introspect.py @@ -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) diff --git a/main.py b/main.py index e8ac04c..f0bc2a0 100644 --- a/main.py +++ b/main.py @@ -186,8 +186,8 @@ pip install "blender-python-stubs>={major_minor},<{next_minor}" import bpy obj = bpy.context.active_object -if obj is not None: - print(obj.name) +assert obj is not None +obj.location.x = 1.0 bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh")) ``` diff --git a/overrides/5.1/gpu.types.json b/overrides/5.1/gpu.types.json new file mode 100644 index 0000000..cc0037f --- /dev/null +++ b/overrides/5.1/gpu.types.json @@ -0,0 +1,7 @@ +{ + "GPUShader.uniform_float": { + "params": { + "value": "float | int | Sequence[float] | mathutils.Matrix | mathutils.Vector | mathutils.Euler | mathutils.Quaternion | mathutils.Color" + } + } +}