transform_component
Adjust a component's position, rotation, or scale in Sketchup using the SketchupMCP server. Simplify 3D model manipulation by directly modifying component properties.
Instructions
Transform a component's position, rotation, or scale
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| position | No | ||
| rotation | No | ||
| scale | No |
Implementation Reference
- src/sketchup_mcp/server.py:312-341 (handler)The handler function for the 'transform_component' MCP tool. It connects to the Sketchup extension via a socket, prepares arguments for position, rotation, or scale, and sends a JSON-RPC 'tools/call' request to Sketchup's corresponding tool. Includes error handling and logging.@mcp.tool() def transform_component( ctx: Context, id: str, position: List[float] = None, rotation: List[float] = None, scale: List[float] = None ) -> str: """Transform a component's position, rotation, or scale""" try: sketchup = get_sketchup_connection() arguments = {"id": id} if position is not None: arguments["position"] = position if rotation is not None: arguments["rotation"] = rotation if scale is not None: arguments["scale"] = scale result = sketchup.send_command( method="tools/call", params={ "name": "transform_component", "arguments": arguments }, request_id=ctx.request_id ) return json.dumps(result) except Exception as e: return f"Error transforming component: {str(e)}"
- src/sketchup_mcp/server.py:312-312 (registration)The @mcp.tool() decorator registers the transform_component function as an MCP tool, automatically using the function name as the tool name.@mcp.tool()
- src/sketchup_mcp/server.py:313-319 (schema)The function signature defines the input schema with type hints: required 'id' (str), optional 'position', 'rotation', 'scale' as lists of floats, returning a JSON string.def transform_component( ctx: Context, id: str, position: List[float] = None, rotation: List[float] = None, scale: List[float] = None ) -> str: