Skip to main content
Glama

get_view

Capture screenshots of 3D CAD designs from specific viewpoints like Isometric, Front, Top, and other orientations for documentation and review purposes.

Instructions

Get a screenshot of the active view.

Args: view_name: The name of the view to get the screenshot of. The following views are available: - "Isometric" - "Front" - "Top" - "Right" - "Back" - "Left" - "Bottom" - "Dimetric" - "Trimetric" Returns: A screenshot of the active view.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
view_nameYes

Implementation Reference

  • The primary handler for the 'get_view' tool. It is registered via the @mcp.tool() decorator and implements the logic to retrieve a screenshot from the specified FreeCAD view by calling the helper method.
    @mcp.tool() def get_view(ctx: Context, view_name: Literal["Isometric", "Front", "Top", "Right", "Back", "Left", "Bottom", "Dimetric", "Trimetric"]) -> list[ImageContent | TextContent]: """Get a screenshot of the active view. Args: view_name: The name of the view to get the screenshot of. The following views are available: - "Isometric" - "Front" - "Top" - "Right" - "Back" - "Left" - "Bottom" - "Dimetric" - "Trimetric" Returns: A screenshot of the active view. """ freecad = get_freecad_connection() screenshot = freecad.get_active_screenshot(view_name) if screenshot is not None: return [ImageContent(type="image", data=screenshot, mimeType="image/png")] else: return [TextContent(type="text", text="Cannot get screenshot in the current view type (such as TechDraw or Spreadsheet)")]
  • Supporting helper method in the FreeCADConnection class used by get_view to safely obtain a screenshot, including view compatibility checks.
    def get_active_screenshot(self, view_name: str = "Isometric") -> str | None: try: # Check if we're in a view that supports screenshots result = self.server.execute_code(""" import FreeCAD import FreeCADGui if FreeCAD.Gui.ActiveDocument and FreeCAD.Gui.ActiveDocument.ActiveView: view_type = type(FreeCAD.Gui.ActiveDocument.ActiveView).__name__ # These view types don't support screenshots unsupported_views = ['SpreadsheetGui::SheetView', 'DrawingGui::DrawingView', 'TechDrawGui::MDIViewPage'] if view_type in unsupported_views or not hasattr(FreeCAD.Gui.ActiveDocument.ActiveView, 'saveImage'): print("Current view does not support screenshots") False else: print(f"Current view supports screenshots: {view_type}") True else: print("No active view") False """) # If the view doesn't support screenshots, return None if not result.get("success", False) or "Current view does not support screenshots" in result.get("message", ""): logger.info("Screenshot unavailable in current view (likely Spreadsheet or TechDraw view)") return None # Otherwise, try to get the screenshot return self.server.get_active_screenshot(view_name) except Exception as e: # Log the error but return None instead of raising an exception logger.error(f"Error getting screenshot: {e}") return None

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