Selva Compute API Reference - v1.1.2
    Preparing search index...

    Class GrasshopperResponseProcessor

    High-level wrapper for interacting with Grasshopper Compute responses.

    This class exposes a clean, consistent API for accessing parsed values, geometry, and produced files. It is designed to be the primary interface when working with Grasshopper results in client applications.

    Index

    Constructors

    Methods

    • Convert all geometry results into Three.js mesh objects.

      This uses internal helpers to decode Rhino geometry into Three.js primitives such as meshes and lines, making them ready for rendering.

      All processing options (scaling, positioning, compression, etc.) can be customized. The processor's debug flag is merged with options - explicit options take precedence.

      Note: This only works when using the Selva Display component in Grasshopper, and requires the custom branch of rhino.compute from VektorNode. This method dynamically imports three.js visualization modules. Ensure three.js is installed as a peer dependency if you use this feature.

      Parameters

      • Optionaloptions: MeshExtractionOptions

        Configuration for mesh extraction and parsing. Overrides processor's debug flag if provided.

      Returns Promise<
          Mesh<
              BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>,
              Material | Material[],
              Object3DEventMap,
          >[],
      >

      Promise resolving to an array of Three.js mesh objects.

      If three.js visualization module cannot be loaded.

      const meshes = await processor.extractMeshesFromResponse();
      scene.add(...meshes);
      const meshes = await processor.extractMeshesFromResponse({
      debug: true,
      allowScaling: true,
      allowAutoPosition: false,
      parsing: {
      mergeByMaterial: false,
      applyTransforms: true,
      debug: true,
      },
      });
    • Download all files generated by Grasshopper, optionally including additional user-provided files.

      Files are grouped under the specified folder name when downloaded.

      Parameters

      • folderName: string

        Name for the download directory.

      • OptionaladditionalFiles: FileBaseInfo | FileBaseInfo[] | null

        Extra files to package (single file, array, or null).

      Returns void

      processor.getAndDownloadFiles('gh-output');
      
      const extra = { name: 'notes.txt', data: 'Example' };
      processor.getAndDownloadFiles('project', extra);
    • Retrieve a specific value using the parameter ID.

      Parameters

      • paramId: string

        Parameter GUID from the Grasshopper definition.

      • Optionaloptions: GetValuesOptions

        Parsing configuration (e.g. disable parsing or enable Rhino).

      Returns any

      Parsed value, array of values, or undefined if not present.

      const output = processor.getValueByParamId('a4be1c1e-23f9-4c27-b942-7f3bb2c45c6f');
      
    • Retrieve a specific value using the parameter name.

      Parameters

      • paramName: string

        Human-readable parameter name from the Grasshopper definition.

      • Optionaloptions: GetValuesOptions

        Parsing configuration (e.g. disable parsing or enable Rhino).

      Returns any

      Single parsed value, array of values, or undefined if the parameter is absent.

      const schema = processor.getValueByParamName('Schema');
      
    • Extract all values in the response.

      Type Parameters

      • T = ParsedContext

        Expected structure of the return value. Defaults to a simple key/value map. (later cast as needed)

      Parameters

      • byId: boolean = false

        If true, keys are parameter IDs; if false, keys are parameter names.

      • options: GetValuesOptions = {}

        Controls parsing behavior such as Rhino geometry decoding.

      Returns GetValuesResult<T>

      Parsed Grasshopper output values.

      Note: Using byId only works with the custom VektorNode rhino.compute branch.

      const processor = new GrasshopperResponseProcessor(response);
      const { values } = processor.getValues();
      const { values } = processor.getValues(true); // keyed by param ID