Skip to main content
Glama

get_view

Capture a screenshot of the active view in FreeCAD MCP. Specify the view name (e.g., Isometric, Front, Top) to generate a precise visual representation of your 3D design.

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 handler function for the get_view tool. It uses the FreeCADConnection to get a screenshot from the specified view and returns it as an image or a text message if unavailable. Registered via @mcp.tool() decorator.
    @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)")]
  • Helper method in FreeCADConnection class that checks if the current FreeCAD view supports screenshots and retrieves the screenshot data for the specified view_name, used by get_view and other tools.
    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