This VS Code extension allows users to send Python scripts from VS Code to a Grasshopper listener component for execution.
Features
- Easily send Python or C# scripts to Grasshopper with a single command.
- Works with a Grasshopper HTTP listener to process and execute the code.
Usage
- Install the extension in VS Code.
- Open a Python file or c# file
- Press
F3 to send the current Python script to the Grasshopper listener.
- Press
F4 to send the current c# script to the Grasshopper listener.
Installation
From the Marketplace
- Install the extension directly from the Visual Studio Code marketplace.
Manual Installation
- Download the
.vsix file.
- In VS Code, go to Extensions (
Ctrl+Shift+X ), click on the three dots in the top right corner, and select Install from VSIX.
Example
// #! csharp
using System;
using System.Collections.Generic;
using Rhino.Geometry;
List<Point3d> points = new List<Point3d>();
Console.WriteLine("a Shrubbery!!!!..");
if (curve == null)
{
Rhino.RhinoApp.WriteLine("Curve input is null.");
}
else if (count <= 0)
{
Rhino.RhinoApp.WriteLine("Invalid count.");
}
else
{
double curveLength = curve.GetLength();
Rhino.RhinoApp.WriteLine("Curve length: " + curveLength);
Rhino.RhinoApp.WriteLine("Number of points: " + count);
for (int i = 0; i < count; i++)
{
double t = curveLength * i / (count - 1);
Point3d pt = curve.PointAtLength(t);
points.Add(pt);
Rhino.RhinoApp.WriteLine($"Generated point {i + 1}: {pt}");
}
A = points; // Output the list of points
Rhino.RhinoApp.WriteLine($"Total points generated: {points.Count}");
}
| |