mcp 接freecad画齿轮

python 复制代码
from mcp.server.fastmcp import FastMCP
import freecad.gears.commands
import os
from freecad import app
from freecad import part
mcp = FastMCP("Demo")

@mcp.tool()
def create_gear(num_teeth=20,height=10,double_helix= True):
     """
     创建一个渐开线齿轮并导出为 STEP 文件。

     参数:
          num_teeth (int): 齿轮的齿数,默认值为 20。
          height (float): 齿轮的高度(厚度),默认值为 10。
          double_helix (bool): 是否启用双螺旋,默认值为 True。
     
     返回:
           savepath:生成的齿轮保存地址。
     """
     app.newDocument()
     gear = freecad.gears.commands.CreateInvoluteGear.create()
     gear.num_teeth = num_teeth
     gear.height = height
     gear.double_helix = double_helix
     app.ActiveDocument.recompute()
     savepath = os.path.join(os.path.dirname(__file__), "gear.step")
     part.export([gear], savepath)
     return savepath



if __name__ == "__main__":
     mcp.run()
 

mcp 接freecad画齿轮_哔哩哔哩_bilibili

相关推荐
会飞的小蛮猪4 小时前
ELK运维之路(Logstash-插件)
运维·经验分享·elk·elasticsearch·logstash
LaughingZhu8 小时前
Product Hunt 每日热榜 | 2025-10-25
人工智能·经验分享·搜索引擎·产品运营
TeleostNaCl16 小时前
OpenWrt | 实现限制只有指定设备才能访问 luci 和 使用 SSH 等方式管理设备的方法
网络·经验分享·ssh·智能路由器
哈喽哈喽哈喽~1 天前
推送文件到github ---服务器关键配置内容
运维·服务器·经验分享·github
北方的流星1 天前
更换MacbookAir固态硬盘,并用U盘安装MacOS操作系统
经验分享·macos·学习方法
源代码•宸1 天前
Qt6 学习——一个Qt桌面应用程序
开发语言·c++·经验分享·qt·学习·软件构建·windeployqt
落798.1 天前
【在昇腾NPU上部署Llama-2-7B:从环境配置到性能测试的完整实战】
经验分享·llama·1024程序员节
LaughingZhu1 天前
Product Hunt 每日热榜 | 2025-10-26
人工智能·经验分享·搜索引擎·产品运营