-
Couldn't load subscription status.
- Fork 2.2k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I was actually trying to illustrate a bug in Blender's gltf importer when I ran into this. Basically, the script always returns exit code 245 (despite running properly without raising an exception), but when run via uv run, the returned code is always 1. Technically, I supposed that is correct, but it seems like it would be nice to have the actual exit code of the script being run returned. Here is the script for reference:
#!/usr/bin/env python
# /// script
# requires-python = ">=3.11,<3.12"
# dependencies = [
# "bpy",
# "typer",
# ]
# ///
from pathlib import Path
from typing import (
Any,
Sequence,
)
import bpy
import bpy_types
import typer
app = typer.Typer()
def load_gltf(file_path: Path) -> Sequence[bpy_types.Object]:
"""Import a gltf file into the current scene.
Parameters
----------
file_path : Path
The path to the gltf file to import.
Returns
-------
Sequence[bpy_types.Object]
The selected objects after the gltf is imported.
"""
op_params: dict[str, Any] = {
"filepath": str(file_path),
}
bpy.ops.import_scene.gltf(**op_params)
return bpy.context.selected_objects
@app.command()
def import_gltf(file_path: Path):
"""CLI command to import a gltf file."""
objects = load_gltf(file_path)
typer.echo(f"Imported {len(objects)} objects.")
if __name__ == "__main__":
app()Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working