Skip to content

API Reference

This page provides an overview of the internal Python API for the Argos Blender Addon.

Core Addon Logic

src

Builder and Binary Management

src.builder

Functions

install(operator=None)

Orchestrates the installation of the Argos toolkit.

Depending on the configuration, this will either download a pre-compiled release from GitHub or build the toolkit from source (if ARGOS_DEBUG is true).

Parameters:

Name Type Description Default
operator Operator

The Blender operator instance for reporting status.

None
Source code in src/builder.py
def install(operator=None):
    """
    Orchestrates the installation of the Argos toolkit.

    Depending on the configuration, this will either download a pre-compiled
    release from GitHub or build the toolkit from source (if ARGOS_DEBUG is true).

    Args:
        operator (bpy.types.Operator, optional): The Blender operator instance for reporting status.
    """
    global _bin_path
    if operator: operator.report({'INFO'}, "Argos: Starting install and build...")

    is_debug = config.is_debug()
    project_dir = config.get_project_dir()
    os.makedirs(os.path.dirname(project_dir), exist_ok=True)

    try:
        if(is_debug):
            _bin_path = _install_dev(project_dir)
        else:
            _bin_path = _install()
    except Exception as e:
        if operator: operator.report({'ERROR'}, f"Unexpected error: {str(e)}")
        raise e

Configuration

src.config

Configuration management for the Argos Blender Addon.

This module handles versioning, paths, and environment-based settings (like debug mode).

Functions

get_argos_version()

Returns the version of the Argos toolkit expected by the addon.

Source code in src/config.py
def get_argos_version() -> str:
    """Returns the version of the Argos toolkit expected by the addon."""
    return _ARGOS_VERSION

get_bin_name()

Returns the platform-specific binary name for the Argos toolkit.

Source code in src/config.py
def get_bin_name():
    """Returns the platform-specific binary name for the Argos toolkit."""
    return "argos.exe" if _system_raw == "Windows" else "argos"

get_dev_repo_url()

Returns the URL for the development repository (GitHub).

Source code in src/config.py
def get_dev_repo_url():
    """Returns the URL for the development repository (GitHub)."""
    return f"https://{_GITHUB_HOST}/{_REPO_OWNER}/{_REPO_NAME}.git"

get_github_host()

Returns the GitHub host name (e.g., github.com).

Source code in src/config.py
def get_github_host() -> str:
    """Returns the GitHub host name (e.g., github.com)."""
    return _GITHUB_HOST

get_project_dir()

Returns the absolute path to the Argos installation directory.

Depends on whether we are in debug mode or not.

Source code in src/config.py
def get_project_dir() -> str:
    """
    Returns the absolute path to the Argos installation directory.

    Depends on whether we are in debug mode or not.
    """
    argos_dir = _get_argos_dir()
    if is_debug():
        return str(argos_dir / "dev")
    else:
        return str(argos_dir / "project")

get_release_url()

Returns the direct download URL for the pre-compiled Argos release.

Source code in src/config.py
def get_release_url():
    """Returns the direct download URL for the pre-compiled Argos release."""
    return f"https://{_GITHUB_HOST}/{_REPO_OWNER}/{_REPO_NAME}/releases/download/v{_ARGOS_VERSION}/ARGOS-{_ARGOS_VERSION}-{_system}{_system_ext}"

get_system_ext()

Returns the platform-specific archive extension for Argos releases.

Source code in src/config.py
def get_system_ext() -> str:
    """Returns the platform-specific archive extension for Argos releases."""
    return _system_ext

get_system_name()

Returns the platform-specific name used in Argos release filenames.

Source code in src/config.py
def get_system_name() -> str:
    """Returns the platform-specific name used in Argos release filenames."""
    return _system

is_debug()

Checks if the addon is running in debug/development mode.

Returns:

Name Type Description
bool bool

True if ARGOS_DEBUG environment variable is 'true'.

Source code in src/config.py
def is_debug() -> bool:
    """
    Checks if the addon is running in debug/development mode.

    Returns:
        bool: True if ARGOS_DEBUG environment variable is 'true'.
    """
    return os.getenv("ARGOS_DEBUG") == "true"

UI and Operator Logic

src.gui

Functions

build_command_property_groups(cmd_list)

Create a PropertyGroup subclass for each command's arguments.

Returns a list of (command_name, cls) tuples.

Source code in src/gui/props.py
def build_command_property_groups(cmd_list: list[commands.Command]):
    """Create a PropertyGroup subclass for each command's arguments.

    Returns a list of (command_name, cls) tuples.
    """
    groups = []
    for cmd_def in cmd_list:
        annotations = {}
        for arg_def in cmd_def.args:
            annotations[arg_def.name] = _make_property(arg_def)

        cls_name = f"ARGOS_PG_cmd_{cmd_def.name}"
        cls = type(cls_name, (bpy.types.PropertyGroup,), {"__annotations__": annotations})
        groups.append((cmd_def.name, cls))

    return groups

build_enum_items(cmd_list)

Build the items list for the command selector EnumProperty.

Source code in src/gui/props.py
def build_enum_items(cmd_list: list[commands.Command]):
    """Build the items list for the command selector EnumProperty."""
    return [
        (cmd.name, cmd.label, cmd.description)
        for cmd in cmd_list
    ]

build_type_enum_items(cmd_list, project_type)

Build enum items filtered by project type.

Source code in src/gui/props.py
def build_type_enum_items(cmd_list: list[commands.Command], project_type: str):
    """Build enum items filtered by project type."""
    return [
        (cmd.name, cmd.label, cmd.description)
        for cmd in cmd_list
        if cmd.project_type == project_type
    ]

Commands and Algorithm Discovery

src.commands

Classes

Argument dataclass

Represents a single command-line argument for an algorithm.

Source code in src/commands.py
@dataclass
class Argument:
    """Represents a single command-line argument for an algorithm."""
    name: str
    flag: str
    type: str
    label: str
    description: str
    default: int

Command dataclass

Represents a full algorithm with its metadata and arguments.

Source code in src/commands.py
@dataclass
class Command:
    """Represents a full algorithm with its metadata and arguments."""
    name: str
    label: str
    description: str
    args: list[Argument]
    project_type: str = ""

Functions

get_command(name)

Look up a single command definition by name.

Parameters:

Name Type Description Default
name str

The machine name of the command (e.g., 'subdivide').

required

Returns:

Type Description
Command | None

The command definition, or None if not found.

Source code in src/commands.py
def get_command(name: str) -> Command | None:
    """
    Look up a single command definition by name.

    Args:
        name: The machine name of the command (e.g., 'subdivide').

    Returns:
        The command definition, or None if not found.
    """
    for cmd in _COMMANDS:
        if cmd.name == name:
            return cmd
    return None

get_commands_by_type(project_type)

Get all commands matching a project type.

Parameters:

Name Type Description Default
project_type str

The project type to filter by (e.g., 'point_cloud', 'reconstruction').

required

Returns:

Type Description
list[Command]

A list of Command objects matching the project type.

Source code in src/commands.py
def get_commands_by_type(project_type: str) -> list[Command]:
    """
    Get all commands matching a project type.

    Args:
        project_type: The project type to filter by (e.g., 'point_cloud', 'reconstruction').

    Returns:
        A list of Command objects matching the project type.
    """
    return [cmd for cmd in _COMMANDS if cmd.project_type == project_type]

load_commands(cmds_dict=None, operator=None)

Parses a JSON string from the Argos binary to load available commands.

Parameters:

Name Type Description Default
json_string

The raw JSON output from argos info_algos.

required
operator

Optional Blender operator for UI reporting.

None

Returns:

Type Description
list

A list of loaded Command objects.

Source code in src/commands.py
def load_commands(cmds_dict=None, operator=None) -> list:
    """
    Parses a JSON string from the Argos binary to load available commands.

    Args:
        json_string: The raw JSON output from `argos info_algos`.
        operator: Optional Blender operator for UI reporting.

    Returns:
        A list of loaded Command objects.
    """
    global _COMMANDS
    if operator: operator.report({'INFO'}, "Argos: Parsing algorithms...")
    try:
        _COMMANDS = []
        for key in cmds_dict:
            json_string = cmds_dict[key]
            data = json.loads(json_string)

            for algo in data.get("algos", []):

                args: list[Argument] = []
                for param in algo.get("params", []):
                    flag_str = param.get("args", "")
                    if not flag_str:
                        continue
                    flag = flag_str.split(",")[0]
                    name = flag.lstrip("-")
                    typ = param.get("type")
                    if typ is None:
                        typ = "INT"

                    args.append(Argument(**{
                        "name": name,
                        "flag": flag,
                        "type": typ,
                        "label": name.title(),
                        "description": param.get("description", ""),
                        "default": 0,
                        }))

                _COMMANDS.append(Command(**{
                    "name": algo["name"],
                    "label": algo["name"].replace("_", " ").title(),
                    "description": algo["description"],
                    "args": args,
                    "project_type": key,
                    }))

        if operator:
            operator.report({'INFO'}, f"Argos: Loaded {len(_COMMANDS)} algorithms.")
        return _COMMANDS
    except Exception as e:
        err = f"Argos: Error parsing commands JSON: {str(e)}"
        if operator: operator.report({'ERROR'}, err)
        print(f"ERROR {err}")
        raise e

Geometry Marshalling

src.marshaller

Functions

marshal_selected_objects()

Marshals the selected objects.

Returns:

Name Type Description
str str

The OBJ formatted string represetation of the selected objects.

Source code in src/marshaller.py
def marshal_selected_objects() -> str:
    """
    Marshals the selected objects.

    Returns:
        str: The OBJ formatted string represetation of the selected objects.
    """
    with tempfile.NamedTemporaryFile(suffix=".obj", delete=False) as tmp:
        tmp_path = tmp.name
    mtl_path = tmp_path.replace(".obj", ".mtl")

    try:
        bpy.ops.wm.obj_export(
            filepath=tmp_path,
            export_selected_objects=True,
        )
        with open(tmp_path, 'r') as f:
            result = f.read()
    finally:
        if os.path.exists(tmp_path): os.unlink(tmp_path)
        if os.path.exists(mtl_path): os.unlink(mtl_path)

    return result

unmarshal_and_import(object_str)

Unmarshals the objects represented by object_str and import them into the viewport. Args: object_str (str): The OBJ formatted representation of the objects to import.

Returns:

Name Type Description
list list

The list of newly imported objects.

Source code in src/marshaller.py
def unmarshal_and_import(object_str: str) -> list:
    """
    Unmarshals the objects represented by object_str and import them into the viewport.
    Args:
        object_str (str): The OBJ formatted representation of the objects to import.

    Returns:
        list: The list of newly imported objects.
    """

    with tempfile.NamedTemporaryFile(
        suffix=".obj", delete=False, mode='w', encoding='utf-8'
    ) as tmp:
        tmp.write(object_str)
        tmp_path = tmp.name

    before = set(bpy.data.objects)
    try:
        bpy.ops.wm.obj_import(filepath=tmp_path)
    finally:
        if os.path.exists(tmp_path): os.unlink(tmp_path)

    new_objects = [o for o in bpy.data.objects if o not in before]

    return new_objects