Giter Club home page Giter Club logo

rhino-developer-samples's Introduction

Rhino Developer Samples

This repository contains all the sample developer code for programming in the Rhino and Grasshopper ecosystem.

The source of this repository will be used to populate the Samples section of the Rhino Developer website.

Much like the Rhino Developer website, the version of Rhino that these samples are compatible with are determined by which branch of this repository one is viewing:

  • The master branch corresponds to the version of Rhino currently in active development (the WIP branch).
  • The 7 branch correspondes to Rhino 7, the 6 branch corresponds to Rhino 6, etc.
  • Older versions of Rhino will be archived into version-specific branches (for example: 5).

Samples by SDK or Language

The samples in this repository are organized by folders that correspond to the different SDKs that make up the Rhino development platform. For more information about the different Rhino SDKs and supported languages, please see the Rhino Developer website. This repository contains samples for:

Building Samples

TODO: More info about building coming soon.

Why are the sample projects prefixed with the word Sample?

We gave each sample project a unique name in order to avoid command name collisions when these samples are run in Rhino. The word Sample is prefixed to distinguish it from developer "Test" commands that sometimes used to test out new functionality in Rhino. Since it is possible - and probable - that samples might be built, run, and tested in multiple languages, so we opted for a language code (C/C++ samples omit this simply because they came first), before the name of the sample.

Testing

TODO: More info coming soon

rhino-developer-samples's People

Contributors

acormier avatar andresjacobo avatar andylebihan avatar croudyj avatar dalefugier avatar dan-rigdon-bel avatar davidrutten avatar deranen avatar fraguada avatar golsby avatar jesterking avatar johnmorse avatar jussiaaltonen avatar matulski avatar pearswj avatar piac avatar sbaer avatar scotttd avatar sodermax avatar travisserio avatar uozcan12 avatar zooid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rhino-developer-samples's Issues

C++ export and import data

I am writing a utility to operate on rhino files so I can export the mesh data.
Is that supported on your api ? Not sure if you provide file level api you see ..

Next I want to write a plug-in to pull and push data via the rhino program itself. The idea is to update the mesh as the architect works. I assume that I need some sort of developer account to allow my colleagues to use that ?

Converting OBJ to 3DM: Validity Issues in Generated Files

I’m attempting to load and convert an OBJ file to 3DM format using the rhino3dm library. Here’s the relevant code snippet:

import rhino3dm from 'rhino3dm';
import * as fs from 'fs';
import * as THREE from 'three';
import { OBJLoader } from 'three/addons/loaders/OBJLoader.js';

const rhino = await rhino3dm();
console.log('Loaded rhino3dm.');

const fileContent = fs.readFileSync('public/models/test.obj').toString();

const loader = new OBJLoader();
const obj = loader.parse(fileContent);

let exportGeometry = null;
if (obj.children) {
    obj.children.forEach((mesh) => {
        if (!exportGeometry) {
            console.log('here');
            exportGeometry = mesh.geometry;
        } else {
            exportGeometry = THREE.BufferGeometryUtils.mergeBufferGeometries([exportGeometry, mesh.geometry], false);
        }
    });
}
const rhinoMesh = rhino.Mesh.createFromThreejsJSON({data: exportGeometry})

const doc = new rhino.File3dm()
doc.objects().add(rhinoMesh, null)

let opts = new rhino.File3dmWriteOptions()
opts.version = 6;
let buffer = doc.toByteArrayOptions(opts);
fs.writeFileSync('public/models/test.3dm', buffer);
console.log('3DM file saved successfully.');

The code successfully generates a 3DM file, but unfortunately, the resulting file is not valid. When re-uploaded to a 3D viewer, it fails to load properly. I’ve followed the example from the repository, but I’m encountering this issue.

Any insights on why the generated 3DM file isn’t valid, and how I can address this problem?

Unable to use delete and enter keys

_rhinoCore = new Rhino.Runtime.InProcess.RhinoCore( Rhino.Runtime.InProcess.WindowStyle.Maximized);

The Rhino program opened using this code cannot use the Delete and Enter keys, but can be used by opening Rhino separately. But typing the command 'delete' can be used

How to add command for SampleMeshExport

I am a beginer of Rhino developer and have successfully complied the SampleExportMesh. I want to known how to add a command to call the function to export a mesh to a file?

SampleViewportRenderer doesn't work in Rhino 6

Hi,

I originally came across this issue in our own CRhinoDisplayPipeline implementation however I encounter the same thing in the SampleViewportRenderer in this repo.

In short, it doesn't work. When you activate the renderer nothing ever gets displayed in the viewport. It just keeps displaying whatever was there previously and if you navigate the display remains unchanged.

I can fix this by providing a derived implementation of the EngineClass() virtual method. EG:

const ON_ClassId* CSampleDisplayPipeline::EngineClass()
{
	return &CRhinoDisplayEngine_OGL::m_CRhinoDisplayEngine_OGL_class_rtti;
}

On my machine I then get the viewport renders.

If I change the EngineClass() implementation to just return CRhinoDisplayPipeline::EngineClass() then things stop working again. In fact, the EngineClass() method gets called about 15 times. When it returns the OGL engine class it only gets called once.

Unfortunately, even though with these fixes it works on my desktop development machine it does not work on the laptop we tested. The ShowFrameBuffer method gets called however the viewport never gets updated. The only real difference we can think of between the two machines is that the laptop has an integrated and dedicated GPU (Rhino is running on the dedicated) while the development machine is just a dedicated GPU. So far we've only tested one desktop and one laptop but will be trying another laptop tomorrow. However, I can't think why there should be any issue given that ShowFrameBuffer is working at the MFC/WindowsSDK level.

Note that the Rhino 5 version of the plugins (both sample and our one) works fine in all cases. It's only for Rhino 6 that we've needed to override EngineClass() and are encountering the laptop issue.

rhino.inside/dotnet/SampleRunGrasshopper is still working?

Hi @fraguada,

I am not able to make work your sample project:

https://github.com/mcneel/rhino-developer-samples/blob/7/rhino.inside/dotnet/SampleRunGrasshopper/Program.cs

I have the nuget libraries and using .NET 4.8.
image

But when I run I got:
System.MissingMethodException: 'Method not found: 'Void Grasshopper.Plugin.GH_RhinoScriptInterface.RunHeadless()'.'
at


For some reason looks like is referencing other Grasshopper.dll version, so I tried subscribing to AppDomain.CurrentDomain.AssemblyResolve to load the Grasshopper.dll from the Rhino 7 Plug-ins folder, but after that in the same code line I got System.NullReferenceException: 'Object reference not set to an instance of an object.'.

Could you or someone look into this please?

Thanks.

why not must setPath librayPath?

When I am using 3dmLoader, why do I have to set the librarypath? Can this step be omitted?

just,like-this:

loader = new Rhino3dmLoader();
// loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/[email protected]/' );
loader.load( 'http://127.0.0.1:5502/shoe/shoe.3dm', function ( object ) {
debugger
console.log(object);1
scene.add( object );
render()
}, (e) => {
		console.log(e)
}, (e) => {
		console.log(e)
})

not

// open 
loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/[email protected]/' );

help !

Unable to load RhinoLibrary dll while running HelloWorld sample

Hello ! I tried to run the hello world example in C# but I get an error at this line using (new RhinoCore(args)) :
System.DllNotFoundException : 'unable to load 'RhinoLibrary' DLL: The specified module cannot be found. (HRESULT exception : 0x8007007E)'

I re-referenced RhinoCommon and Rhino.Inside from the NuGet packages just to be sure. But I still get the issue...

Am I missing a setting step?

ResetBlock.rvb throws 'undefined variable' error

The script ResetBlock.rvb throws an 'undefined variable: arrXform' error.
This can be fixed by adding arrXform to the Dim declarations on line 17, since the script uses Option Explicit:
Dim arrBlocks, strBlock, arrPoint, arrVector, arrXform

rhino.inside/dotnet/SampleUnitTests does not work

I have cloned rhino developer samples inside visual studio 2019 (16.11.3) starting from the opening dialog to clone a project.
Then opened the Rhino.Inside SampleUnitTests & built it, without making any changes (even though the readme.txt suggests to make changes, all these were already done or set correctly).

When I use the Visual Studio built-in unit test running facilities, I first get an error that Grasshopper.dll is not found. I see that all the NuGet packages (rhino.inside, rhinowindows, grasshopper, rhinocommon) are installed in the %USER%.nuget\packages directory, but the dependent DLL's are not copied over to the directory where the unit test runner can find them. So, I copied over all dependent DLLs from nuget packages into the build output directory. Then I get a different error (see below), and I am stuck trying to solve this.

I was hoping to just clone, build and run the unit tests project without any hassle.

System.DllNotFoundException
Unable to load DLL 'RhinoLibrary': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Rhino.Runtime.InProcess.RhinoCore.InternalStartup(Int32 argc, String[] argv, StartupInfo& info, IntPtr hostWnd)
   at Rhino.Runtime.InProcess.RhinoCore..ctor(String[] args, WindowStyle windowStyle, IntPtr hostWnd)
   at Rhino.Test.GrasshopperSingleton.InitializeCore() in D:\zandbak\rhino-developer-samples\rhino.inside\dotnet\SampleUnitTests\GrasshopperTests\GrasshopperFixture.cs:line 148
   at Rhino.Test.GrasshopperSingleton..ctor() in D:\zandbak\rhino-developer-samples\rhino.inside\dotnet\SampleUnitTests\GrasshopperTests\GrasshopperFixture.cs:line 117
   at Rhino.Test.GrasshopperSingleton.get_Instance() in D:\zandbak\rhino-developer-samples\rhino.inside\dotnet\SampleUnitTests\GrasshopperTests\GrasshopperFixture.cs:line 90
   at Rhino.Test.GHFileFixture..ctor(String filePath) in D:\zandbak\rhino-developer-samples\rhino.inside\dotnet\SampleUnitTests\GrasshopperTests\GrasshopperFixture.cs:line 24
   at SampleGHTests.PrimitivesFixture..ctor() in D:\zandbak\rhino-developer-samples\rhino.inside\dotnet\SampleUnitTests\GrasshopperTests\TestPrimitives.cs:line 17

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.