Skip to main content
Glama

delete_object

Remove specific objects from FreeCAD documents to clean up designs or correct modeling errors. Specify document and object names to delete unwanted elements from your CAD project.

Instructions

Delete an object in FreeCAD.

Args: doc_name: The name of the document to delete the object from. obj_name: The name of the object to delete. Returns: A message indicating the success or failure of the object deletion and a screenshot of the object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_nameYes
obj_nameYes

Implementation Reference

  • Primary MCP tool handler for 'delete_object'. Decorated with @mcp.tool() for automatic registration. Proxies the call to FreeCADConnection.delete_object and formats response with optional screenshot.
    @mcp.tool() def delete_object(ctx: Context, doc_name: str, obj_name: str) -> list[TextContent | ImageContent]: """Delete an object in FreeCAD. Args: doc_name: The name of the document to delete the object from. obj_name: The name of the object to delete. Returns: A message indicating the success or failure of the object deletion and a screenshot of the object. """ freecad = get_freecad_connection() try: res = freecad.delete_object(doc_name, obj_name) screenshot = freecad.get_active_screenshot() if res["success"]: response = [ TextContent(type="text", text=f"Object '{res['object_name']}' deleted successfully"), ] return add_screenshot_if_available(response, screenshot) else: response = [ TextContent(type="text", text=f"Failed to delete object: {res['error']}"), ] return add_screenshot_if_available(response, screenshot) except Exception as e: logger.error(f"Failed to delete object: {str(e)}") return [ TextContent(type="text", text=f"Failed to delete object: {str(e)}") ]
  • Core implementation in FreeCAD RPC server that performs the actual object deletion using FreeCAD.Document.removeObject() in the GUI thread.
    def _delete_object_gui(self, doc_name: str, obj_name: str): doc = FreeCAD.getDocument(doc_name) if not doc: FreeCAD.Console.PrintError(f"Document '{doc_name}' not found.\n") return f"Document '{doc_name}' not found.\n" try: doc.removeObject(obj_name) doc.recompute() FreeCAD.Console.PrintMessage(f"Object '{obj_name}' deleted via RPC.\n") return True except Exception as e: return str(e)
  • RPC server method for delete_object that queues the GUI-safe deletion task and returns success/error response.
    def delete_object(self, doc_name: str, obj_name: str): rpc_request_queue.put(lambda: self._delete_object_gui(doc_name, obj_name)) res = rpc_response_queue.get() if res is True: return {"success": True, "object_name": obj_name} else: return {"success": False, "error": res}
  • Proxy method in FreeCADConnection class that forwards the delete_object call to the XML-RPC server.
    def delete_object(self, doc_name: str, obj_name: str) -> dict[str, Any]: return self.server.delete_object(doc_name, obj_name)

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/heok-yongssun/freecad-mcp'

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