Skip to main content
Glama

delete_object

Remove an object from a FreeCAD document by specifying the document and object names, and confirm deletion with a success message and screenshot.

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 tool handler for delete_object: calls FreeCAD proxy, handles response, adds screenshot feedback.
    @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)}") ]
  • FreeCADConnection proxy method that forwards delete_object call to RPC server.
    def delete_object(self, doc_name: str, obj_name: str) -> dict[str, Any]: return self.server.delete_object(doc_name, obj_name)
  • RPC server endpoint for delete_object: queues GUI task and returns success/error.
    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}
  • Core implementation: performs doc.removeObject(obj_name) 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)

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/neka-nat/freecad-mcp'

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