Shared steps for Grasshopper Python and C# script components. Language templates → csharp-boilerplate.md, python-boilerplate.md.
Create
gh_edit_scriptaction"create":language("python"|"csharp"),source,inputs,outputs.- Each input:
name, optionaltypeHint(objectdefault,double,string, …).
Update code
gh_edit_script"setCode": C# — passscriptParts(preferred) or fullcode. Python — pass fullcode. Include fullinputs/outputswhen the signature changes; omit lists if only code changes.- Small edits:
"patchCode"with line patches — C# default scoperunScriptBody, Python default scopefull(line numbers from file top). - Read split code:
"getCodeParts"— C# only (returnsreferences,runScript,runScriptBody,helpers,lineMap). Python: use"getCode".
Ports only
gh_edit_param"syncParams"— port changes without code changes.- Add/remove/edit params via
gh_edit_paramafter creation.
Rename ports (keep wires)
- Same-order renames in a full
inputs/outputslist apply in place. - Order change or name swap:
{ "name": "radius", "previousName": "r", "typeHint": "double" }. - Omit
previousNamewhen only changingtypeHintor access on an existing name.
Critical
- Renaming a port requires updating the script in the same
setCodecall — matchRunScript/body variable names to new port names. Canvas-only renames break the solution.
mds/reference/script-component-lifecycle.md / View source on GitHub ↗