Skip to main content
Glama

delete_object

Remove a specific object from a FreeCAD document by specifying the document and object names. Returns a confirmation message and a screenshot of the deleted object.

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

  • MCP @mcp.tool() handler and registration for 'delete_object'. Proxies to FreeCAD RPC server and handles response with 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 of object deletion in FreeCAD using doc.removeObject() and recompute(), executed in 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 that queues the GUI 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 delete_object call to 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