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:
- Clarify design requirements and specifications - See references/workflow_steps.md
- Split geometric objects to create part_info.mmd - See references/workflow_steps.md
- Plan the actual battery connection diagram component_info.mmd - See references/workflow_steps.md
- Find the required component GUID and plan positions - See references/workflow_steps.md
- Generate the execution sequence file placement_info.json - See references/workflow_steps.md
- Clean up GH_WIP files - See references/workflow_steps.md
Detailed Documentation
- Workflow Steps: See references/workflow_steps.md - Complete 6-step workflow guide
- API Reference: See references/api_reference.md - Detailed description of all modules and methods
- CLI Usage Instructions: See references/cli_usage.md - Command-line tool usage guide
- Tool Usage Guide: See references/tool_guide.md - Input/output description of all tools
Script Tools
All Python scripts are located in the scripts/ directory:
client.py- MCP communication clientcomponent_manager.py- Component managementconnection_manager.py- Connection managementparameter_setter.py- Parameter settinggroup_manager.py- Group managementparser_utils.py- MMD/JSON parsingplacement_executor.py- Executorutils.py- Utility functionscli.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
Notes
- MCP Server: Ensure the Grasshopper MCP server is running (localhost:8080)
- Component ID Mapping: After a component is created, the ID mapping is automatically saved to
component_id_map.json - Parallel Execution: Parallel execution is supported to improve efficiency; it is recommended to use
max_workers=10to20 - Thread Safety: All operations are thread-safe and can be used in a multithreaded environment
- File Paths: Relative paths in scripts need to be adjusted according to actual usage
Common Workflows
From MMD to a Complete Definition
- Parse
component_info.mmdto obtain component and connection information - Generate the
placement_info.jsonexecution sequence - Execute
placement_info.jsonto create components and connections - Set the parameter values for all sliders
- Create component groups
For detailed steps, see references/workflow_steps.md。