get_object
Retrieve and analyze objects within FreeCAD documents to inspect or modify their properties. Input document and object names to access the target object and generate visual snapshots for design review.
Instructions
Get an object from a document. You can use this tool to get the properties of an object to see what you can check or edit.
Args:
doc_name: The name of the document to get the object from.
obj_name: The name of the object to get.
Returns:
The object and a screenshot of the object.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_name | Yes | ||
| obj_name | Yes |
Implementation Reference
- src/freecad_mcp/server.py:524-548 (handler)MCP tool handler and registration for 'get_object'. This is the primary implementation for the MCP tool, decorated with @mcp.tool(), which registers it and defines the execution logic. It proxies to the FreeCADConnection and adds screenshot feedback.@mcp.tool() def get_object(ctx: Context, doc_name: str, obj_name: str) -> dict[str, Any]: """Get an object from a document. You can use this tool to get the properties of an object to see what you can check or edit. Args: doc_name: The name of the document to get the object from. obj_name: The name of the object to get. Returns: The object and a screenshot of the object. """ freecad = get_freecad_connection() try: screenshot = freecad.get_active_screenshot() response = [ TextContent(type="text", text=json.dumps(freecad.get_object(doc_name, obj_name))), ] return add_screenshot_if_available(response, screenshot) except Exception as e: logger.error(f"Failed to get object: {str(e)}") return [ TextContent(type="text", text=f"Failed to get object: {str(e)}") ]
- Core RPC method implementation of get_object in the FreeCAD addon server. Retrieves the FreeCAD document object using doc.getObject(obj_name) and serializes it.def get_object(self, doc_name, obj_name): doc = FreeCAD.getDocument(doc_name) if doc: return serialize_object(doc.getObject(obj_name)) else: return None
- src/freecad_mcp/server.py:84-85 (helper)Proxy method in FreeCADConnection class that forwards get_object calls to the XML-RPC server.def get_object(self, doc_name: str, obj_name: str) -> dict[str, Any]: return self.server.get_object(doc_name, obj_name)