Rhino Developer Samples

repository·9·Indexed 20 days ago

https://github.com/mcneel/rhino-developer-samples

A collection of developer samples for interacting with Rhino and Rhino Compute across multiple platforms. Includes implementations for Node.js, Electron, Python, C#, and C++, covering topics such as Rhino.Compute API usage, Grasshopper graph solving, Rhino.Inside JavaScript integration, and interoperability between RhinoCommon and Rhino C++ plug-ins.

Tokens
48.8K
Snippets
150
Records
190
Agent score
73%

What's inside rhino-developer-samples

  1. Overview of SampleSharedXform

    9

    SampleSharedXform is a Rhino 6 solution designed to demonstrate how to share application data between RhinoCommon (C#) plug-ins and Rhino C++ plug-ins.

    It achieves this by using a central C++ assembly that maintains a dictionary mapping Rhino object IDs to arrays of 4x4 transformation matrices. Note that this data is runtime-only and is not serialized into Rhino documents.

    The solution is composed of four distinct projects demonstrating different interoperability methods:

    1. SampleSharedXformLib: A Rhino-dependent C++ assembly (DLL) that acts as the data provider/manager.
    2. SampleSharedXformOwner: A RhinoCommon (C#) plug-in that uses Platform Invoke (P/Invoke) to access exported C functions from the library. It has read-write access to the shared dictionary.
    3. SampleSharedXformClient1: A Rhino C++ plug-in that uses Load-Time Dynamic Linking to access the library. It has read-only access to the dictionary.
    4. SampleSharedXformClient2: A Rhino C++ plug-in that uses Run-Time Dynamic Linking to access the library. It has read-only access to the dictionary.
  2. Overview of rhino3dm capabilities

    9

    rhino3dm is a set of libraries based on the OpenNURBS geometry library that follows a "RhinoCommon" style. It allows developers to access and manipulate geometry independently of the Rhino application using .NET, Python, or JavaScript.

    Core Functionality:

    • Geometry Manipulation: Create, interrogate, and store geometry types including points, point clouds, NURBS curves/surfaces, polysurfaces (B-Reps), meshes, annotations, extrusions, and SubDs.
    • Non-Geometry Data: Work with layers, object attributes, transforms, and viewports.
    • File I/O: Read and write .3dm files.
    • Rhino Compute Integration: Act as a client to make calls to the Rhino Compute cloud server for advanced geometry manipulation.
    • Cross-Platform: Supported on Windows, macOS, and Linux.
  3. Overview of Rhino.Compute Samples

    9

    Rhino.Compute provides a stateless REST API running on Windows Servers that allows you to access the Rhino and Grasshopper SDKs. This enables developers to create and manipulate 2D and 3D curves, surfaces, and solids within online solutions or cloud-based frameworks.

    These samples demonstrate how to perform various geometric operations by calling the Rhino.Compute API using different programming languages.

  4. Overview of Rhino.Inside Javascript

    9
    Rhino.Inside Javascript technology enables embedding Rhino and Grasshopper within various JavaScript runtimes and frameworks. This allows developers to leverage Rhino's geometry engine and Grasshopper's computational design capabilities directly within web-based or desktop-based JavaScript environments like Node.js, Electron, and Chromium Embedded Framework (CEF).
  5. Overview of Rhino.Inside® technology

    9

    Rhino.Inside® technology enables embedding Rhino and Grasshopper directly within other 64-bit Windows applications. This allows developers to:

    • Start Rhino and Grasshopper as an add-in within a host product.
    • Call the host's native APIs directly from a Grasshopper or Rhino plugin.
    • Access Rhino's APIs through the host application.
    • Open and preview Grasshopper definitions in Rhino within the same process as the parent application.
    • Natively create Rhino or Grasshopper objects within the parent product.
  6. How to customize display in Rhino 6 and later

    9

    In Rhino 6 and subsequent versions, deriving classes from CRhinoDisplayPipeline is discouraged. Instead, follow these modern patterns for display customization:

    1. Use Conduits: For general customization of the display process, implement conduits.
    2. Use Realtime Rendering: To display real-time rendering results in the viewport without managing the complexities of the display pipeline, use the RhRdk::Realtime::DisplayMode class.
  7. Core Libraries for Rhino.Inside Javascript

    9

    The JavaScript applications rely on specific .NET library projects to bridge the gap between JavaScript runtimes and Rhino:

    • RhinoMethods: Exposes simple methods to start Rhino and perform basic geometry operations (e.g., creating a sphere). Used in Node.js and standard Electron samples.
    • RhinoTaskManager: Provides a task scheduler to manage complex tasks to be run by Rhino. Used in Electron + Grasshopper and CEF samples.