Blender参数化对象生成工具包

一个用于通过MCP生成参数化Blender对象的Python工具包,无需在迭代之间重置Blender会话。

  • by jkantarek
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 jkantarek/blender-mcp-tooling

使用说明

搅拌机mcp工具

一个类型化的Python工具包,用于通过MCP生成参数化Blender对象,而无需在迭代之间重置Blender会话。

每种能力都作为 食谱:一个接受类型化规范并返回一个可通过MCP执行的自包含Blender Python脚本的函数。


它看起来像什么

切削刀具托架板

带有布尔切割半瓦孔图案(八角形+菱形+菱形簇)的边框框架。

透视 顶部

规格: 317.5×165.1毫米框架·0.75英寸边框·10.58毫米厚·14×6网格·336个贯通孔

看 examples/cutting_tool_carrier_v3.py 对于完整的发电机。


食谱——如果你想构建X,就使用Y

结构件

目标 配方 规格
带孔矩形框架 build_frame_part_script() FramePartSpec
戒指(圆形、椭圆形、菱形、定制曲线) build_ring_part_script() RingPartSpec
系带接头 build_tie_part_script() TiePartSpec
Keeper栏 build_keeper_bar_script() KeeperBarSpec
单倒角值的八角形环 build_ring_part_script() + build_chamfered_square_points() RingShape.CUSTOM_CURVE

网格/格子图案

目标 配方 规格
推导八角形+菱形间距几何 build_mesh_cell_spec() MeshCellSpec
铺一块八角形的钻石地 build_mesh_lattice_script() MeshCellLatticeSpec
干净地修剪田地边缘 build_mesh_trim_script() MeshTrimSpec
使用向导引导通风口盖场景 build_scene_foundation_script() FoundationSpec
生成通风口框架封套 build_mesh_frame_script() MeshFrameSpec

图案拼接和切割

目标 配方 规格
在行×列之间平铺一个簇 build_repeat_grid_script() RepeatGridSpec
以几何方式居中放置瓷砖CURVE系列 build_center_pattern_script() collection_name
布尔值在实体上切割一个孔图案 build_boolean_cut_script() 目标+刀具名称

为什么 build_center_pattern_script()? build_repeat_grid_script() 按对象的局部起源放置群集对象。实际的形状顶点(八角形、菱形、菱形控制点)可以相对于世界原点偏离中心几毫米。 build_center_pattern_script() 测量所有POLY样条曲线控制点的真实边界框,并在布尔切割之前对其进行校正。始终在铺瓷砖和切割之间运行。

N-gon基元

目标 配方 规格
任何正多边形 build_ngon_script() NgonSpec
双边对称不规则多边形 build_ngon_script() NgonSpec(vertex_radii=...)
可组合式9槽集群 build_nine_elem_cluster_script() NineElemClusterSpec

验证和审查

目标 配方 规格
放置并检查网格审查副本 build_review_copy_script() MeshReviewSpec
图像差异叠加 uv run blender-mcp-tooling diff-images CLI

承载板的标准管道

from blender_mcp_tooling.application.recipes.repeat_grid import build_repeat_grid_script
from blender_mcp_tooling.application.recipes.center_pattern import build_center_pattern_script
from blender_mcp_tooling.application.recipes.boolean_cut import build_boolean_cut_script

# 1. Tile the cutting pattern
exec(build_repeat_grid_script(request, grid, collection_name="CuttingTool_HalfTile"))

# 2. Geometrically centre it on the carrier (corrects cluster-origin offset)
exec(build_center_pattern_script(request, collection_name="CuttingTool_HalfTile"))

# 3. Boolean-cut through the carrier solid
exec(build_boolean_cut_script(
    request,
    target_object_name="CuttingTool_CarrierPlate",
    cutter_collection_name="CuttingTool_HalfTile",
))

快速食谱示例

带角孔的框架

from blender_mcp_tooling.application.recipes.frame import build_frame_part_script
from blender_mcp_tooling.design import FrameHolePattern, FramePartSpec

frame_spec = FramePartSpec(
    outer_width=317.5,
    outer_height=165.1,
    thickness=10.58,
    inner_opening_width=279.4,
    inner_opening_height=127.0,
    border_left=19.05,
    border_right=19.05,
    border_top=19.05,
    border_bottom=19.05,
    hole_enabled=True,
    hole_pattern=FrameHolePattern.CORNERS,
    hole_diameter=5.0,
    part_name="CuttingTool_BorderFrame",
)

script = build_frame_part_script(request, frame_spec)

圆环

from blender_mcp_tooling.application.recipes.ring import build_ring_part_script
from blender_mcp_tooling.design import RingPartSpec, RingShape

ring_spec = RingPartSpec(
    shape=RingShape.CIRCULAR,
    outer_size=(96.0, 96.0),
    thickness=5.0,
    band_width=10.0,
    part_name="Ring_Circle_01",
)

script = build_ring_part_script(request, ring_spec)

通过倒角方形辅助件形成八角形环

from blender_mcp_tooling.design import build_chamfered_square_points, RingPartSpec, RingShape

outer_pts = build_chamfered_square_points(140.0, 140.0, 28.0)
inner_pts = build_chamfered_square_points(98.0, 98.0, 18.0)

ring_spec = RingPartSpec(
    shape=RingShape.CUSTOM_CURVE,
    outer_size=(140.0, 140.0),
    inner_size=(98.0, 98.0),
    thickness=8.0,
    custom_outer_points=outer_pts,
    custom_inner_points=inner_pts,
    part_name="Ring_ChamferedSquare_01",
)

重复网格簇平铺

from blender_mcp_tooling.application.recipes.repeat_grid import build_repeat_grid_script
from blender_mcp_tooling.domain.repeat_grid import EdgeMode, RepeatGridSpec

grid = RepeatGridSpec(
    cluster=cluster_spec,
    cols=14,
    rows=6,
    col_gap=0.5,
    row_gap=0.5,
    edge_mode=EdgeMode.EDGELESS,
)

script = build_repeat_grid_script(request, grid, collection_name="CuttingTool_HalfTile")

示例

示例 说明
examples/cutting_tool_carrier_v3.py 全端到端切割刀架:框架+刀架+半瓦布尔切割

验证

uv sync --all-groups
uv run ruff check .
uv run mypy src tests
uv run pytest

260个测试·ruff clean·mypy strict(94个源文件)。


命令行界面

# List available Blender MCP tools
uv run blender-mcp-tooling list-tools

# Generate a Markdown plan from reference images
uv run blender-mcp-tooling plan chair \
  --prompt "Create a clean hard-surface chair model" \
  --image references/front.png \
  --image references/side.png

# Generate a parametric vent-cover plan
uv run blender-mcp-tooling plan-vent-cover VentCover12x6 \
  --prompt "12x6 opening vent cover with circle scaffold and layered filigree" \
  --opening-width-in 12 \
  --opening-height-in 6 \
  --frame-margin-in 0.75

# Image diff overlay
uv run blender-mcp-tooling diff-images reference.png canvas.png \
  --output build/outputs/diff.png \
  --format json

源布局

src/blender_mcp_tooling/
├── config.py                        # validated project and output settings
├── design.py                        # top-level public re-exports
├── planner.py                       # image-driven and parametric plan builder
├── tool_catalog.py                  # curated Blender MCP tool catalog
├── domain/
│   ├── cluster_designs.py           # half-tile cluster shape builders
│   ├── frames.py                    # FramePartSpec
│   ├── keeper_bars.py               # KeeperBarSpec
│   ├── mesh_cells.py                # MeshCellSpec, build_mesh_cell_spec()
│   ├── mesh_lattice.py              # MeshCellLatticeSpec
│   ├── mesh_review.py               # MeshReviewSpec
│   ├── mesh_trim.py                 # MeshTrimSpec
│   ├── ngon.py                      # NgonSpec, build_ngon_points()
│   ├── nine_elem_cluster.py         # NineElemClusterSpec
│   ├── repeat_grid.py               # RepeatGridSpec, EdgeMode
│   ├── rings.py                     # RingPartSpec, build_chamfered_square_points()
│   ├── ties.py                      # TiePartSpec
│   └── vents.py                     # VentCoverSpec
└── application/
    └── recipes/
        ├── boolean_cut.py           # build_boolean_cut_script()
        ├── center_pattern.py        # build_center_pattern_script()
        ├── foundation.py            # build_scene_foundation_script()
        ├── frame.py                 # build_frame_part_script()
        ├── keeper_bar.py            # build_keeper_bar_script()
        ├── mesh_carriers.py         # carrier plate helpers
        ├── mesh_frame.py            # build_mesh_frame_script()
        ├── mesh_lattice.py          # build_mesh_lattice_script()
        ├── mesh_trim.py             # build_mesh_trim_script()
        ├── ngon.py                  # build_ngon_script()
        ├── nine_elem_cluster.py     # build_nine_elem_cluster_script()
        ├── repeat_grid.py           # build_repeat_grid_script()
        ├── review.py                # build_review_copy_script()
        ├── ring.py                  # build_ring_part_script()
        ├── tie.py                   # build_tie_part_script()
        └── vent.py                  # build_vent_cover_plan()