SuperAPI AI Directory

grasshopper-workflow

Office & productivity

View repository

Updated 10-15 16:45

About this skill

Grasshopper Workflow Skill

Overview

This skill provides a complete Grasshopper parametric modeling workflow, including component management, connection management, parameter setting, group management, and workflow execution. It integrates the complete process from requirements analysis to final execution.

Core Features

1. Component Management

  • Create, query, and delete components
  • Create multiple components in parallel
  • Component ID mapping management
  • Component GUID query

2. Connection Management

  • Establish connections between components
  • Connect multiple components in parallel
  • Connection error checking and correction
  • Document error diagnosis

3. Parameter Setting

  • Set Number Slider properties
  • Set Vector XYZ components
  • Batch parameter setting
  • Automatic range determination

4. Group Management

  • Create component groups
  • Create groups in batches
  • Customize group colors and names

5. Workflow Execution

  • Parse MMD files (component_info.mmd, part_info.mmd)
  • Generate placement_info.json
  • Execute the complete modeling process
  • Automated script execution

Quick Start

Basic Usage

from scripts.client import GrasshopperClient
from scripts.component_manager import ComponentManager
from scripts.connection_manager import ConnectionManager
from scripts.parameter_setter import ParameterSetter
from scripts.group_manager import GroupManager

# 創建客戶端
client = GrasshopperClient(host="localhost", port=8080)

# 創建組件管理器
comp_mgr = ComponentManager(client)

# 創建組件
component_id = comp_mgr.add_component(
    guid="e2bb9b8d-0d80-44e7-aa2d-2e446f5c61da",
    x=100,
    y=200,
    component_id="SLIDER_WIDTH"
)

Complete Workflow

from scripts.parser_utils import MMDParser, JSONGenerator
from scripts.placement_executor import PlacementExecutor

# 1. 解析 MMD 文件
parser = MMDParser()
components, connections = parser.parse_component_info_mmd("component_info.mmd")

# 2. 生成 placement_info.json
generator = JSONGenerator()
placement_info = generator.generate_placement_info(components, connections)
generator.save_placement_info(placement_info, "placement_info.json")

# 3. 執行
executor = PlacementExecutor()
result = executor.execute_placement_info("placement_info.json")

Workflow Steps

The Grasshopper modeling workflow contains 6 main steps:

  1. Clarify design requirements and specifications - See references/workflow_steps.md
  2. Split geometric objects to create part_info.mmd - See references/workflow_steps.md
  3. Plan the actual battery connection diagram component_info.mmd - See references/workflow_steps.md
  4. Find the required component GUID and plan positions - See references/workflow_steps.md
  5. Generate the execution sequence file placement_info.json - See references/workflow_steps.md
  6. Clean up GH_WIP files - See references/workflow_steps.md

Detailed Documentation

Script Tools

All Python scripts are located in the scripts/ directory:

  • client.py - MCP communication client
  • component_manager.py - Component management
  • connection_manager.py - Connection management
  • parameter_setter.py - Parameter setting
  • group_manager.py - Group management
  • parser_utils.py - MMD/JSON parsing
  • placement_executor.py - Executor
  • utils.py - Utility functions
  • cli.py - Command-line interface

Using Scripts

When a specific operation needs to be performed, the corresponding script can be called:

# 執行 placement_info.json
from scripts.placement_executor import PlacementExecutor
executor = PlacementExecutor()
result = executor.execute_placement_info("placement_info.json", max_workers=10)

Command-Line Tool

Use the CLI tool to perform common tasks:

# 執行 placement_info.json
python scripts/cli.py execute-placement placement_info.json

# 設置所有 slider
python scripts/cli.py set-sliders component_info.mmd

# 群組組件
python scripts/cli.py group-components component_info.mmd

See references/cli_usage.md。

Notes

  1. MCP Server: Ensure the Grasshopper MCP server is running (localhost:8080)
  2. Component ID Mapping: After a component is created, the ID mapping is automatically saved to component_id_map.json
  3. Parallel Execution: Parallel execution is supported to improve efficiency; it is recommended to use max_workers=10 to 20
  4. Thread Safety: All operations are thread-safe and can be used in a multithreaded environment
  5. File Paths: Relative paths in scripts need to be adjusted according to actual usage

Common Workflows

From MMD to a Complete Definition

  1. Parse component_info.mmd to obtain component and connection information
  2. Generate the placement_info.json execution sequence
  3. Execute placement_info.json to create components and connections
  4. Set the parameter values for all sliders
  5. Create component groups

For detailed steps, see references/workflow_steps.md。