Skip to main content
Glama
mhyrr
by mhyrr

transform_component

Adjust the position, rotation, or scale of a 3D component in Sketchup using the MCP server to enable precise model transformations and scene manipulation.

Instructions

Transform a component's position, rotation, or scale

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
positionNo
rotationNo
scaleNo

Implementation Reference

  • Handler function for the transform_component tool. It connects to SketchUp via socket, prepares arguments for position, rotation, scale, and sends a JSON-RPC request to SketchUp's transform_component 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)}"
  • The @mcp.tool() decorator registers this function as an MCP tool named 'transform_component' based on the function name.
    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)}"
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mhyrr/sketchup-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server