�
XfXiH� � �� � d Z ddlZddlmZmZmZ ddlmZmZm Z m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZ dedefd�Zdedefd �Zde defd
�Zdefd�Zde
defd�Zdedefd
�Z dedefd�Z!de
defd�Z"dedefd�Z#dedefd�Z$dedefd�Z%dedefd�Z&dedefd�Z'dedefd�Z(dedefd�Z)dedefd�Z*defd�Z+defd�Z,dedefd�Z-dedefd�Z.dedefd�Z/dedefd�Z0dS )a Blender operations - pure functions that interact with bpy
This module contains all the core Blender operations that perform actual
work with the bpy API. These functions are pure business logic with no
MCP dependencies, making them testable and reusable.
� N)�List�Optional�
TYPE_CHECKING� )�CreateCubeInput�CreateSphereInput�MoveObjectInput�DeleteObjectInput�SelectObjectInput�CreateMaterialInput�AssignMaterialInput�RotateObjectInput�ScaleObjectInput�GetObjectInfoInput�CreateCameraInput�CreateLightInput�RenderSceneInput�CreateCylinderInput�CreatePlaneInput�DuplicateObjectInput�SetActiveCameraInput�
SaveFileInput�
OpenFileInput�input�returnc �8 � ddl }|j j � | j | j �� � |j j }|r&| j |_ d| j � d| j � d| j � �S dS # t $ r Y dS t $ r}d t |� � � �cY d}~S d}~ww xY w)
a�
Create a cube in the Blender scene.
This function demonstrates:
- Using bpy.ops to create mesh primitives
- Accessing the active object after creation
- Setting object properties (name)
- Proper error handling for Blender operations
- Informative return messages
Args:
input: Validated input parameters containing:
- name: Name for the cube object (1-63 characters)
- size: Edge length of the cube (must be > 0.001 and <= 1000.0)
- location: Tuple of (x, y, z) coordinates for cube position
Returns:
Success message with cube details including name, size, and location.
Format: "Successfully created cube '{name}' with size {size} at location {location}"
Raises:
Exception: If Blender operation fails or bpy module is not available.
Returns error message string instead of raising exception.
r N��size�locationzSuccessfully created cube '�' with size �
at location z9Error: Cube created but could not get reference to object�BError: bpy module not found. Tool must run in Blender environment.zError [Create Cube]: )�bpy�ops�mesh�primitive_cube_addr r �context�
active_object�name�ImportError� Exception�str)r r# �cube�es �a/Users/gajanmohanraj/Documents/afterquery/candidate-1767282743/blender_takehome/src/operations.py�create_cuber0 ! s � �20� �
�
�
����'�'����^� (�
�
�
�
�{�(��� O��
�D�I�G�e�j� G� G�"�Z�G� G�6;�n�G� G�
�
O�N��� T� T� T�S�S�S�� 0� 0� 0�/�s�1�v�v�/�/�/�/�/�/�/�/�����0���s$ �A"A'