Rhino.compute generate image without interface

Hello everyone.

I’m trying to render an image from grasshopper model using rhino.compute. But as I understand it, it is impossible to render without having the rhino interface.

At the moment, I have tried using a python script using CaptureToBitmap, but the error occurs in this line:

UnsafeNativeMethods.CRhinoView_CaptureToBitmap(m_runtime_serial_number, nonConstPointer, size.Width, size.Height, IntPtr.Zero)

I also tried to transfer this logic to rhino.compute by creating the Rhino.PlugIns.PlugIn plugin. This method is executed, but bitmap = null.

It turned out to use the RhinoDoc.Export method and save it to pdf, obj. But in this case, it is not possible to use the prepared views and customized display mode, the settings and colors are simply ignored. It is also not possible to assign.

Why is everything so Organised?

  1. There is a website where the user enters the parameters.
  2. Then these parameters are sent to an intermediate server, where they are processed and formed into the required form.
  3. Then a request is sent to rhino.compute along the path /grasshopper with these parameters and the gh-model. Rhino.compute is located on a separate Windows Server.
  4. Rhino.compute performs calculations and the output is: geometry, customized layers, views, display mode, all this is saved to a 3dm file if necessary.

Depending on the parameters, the geometry is returned to the intermediate server, and then to the user (this works), or the generated images (this does not work).

The question is:
Are there any ways to generate images, or send the generated geometry or 3dm file for generation to a third-party service, plugins, render engine? Using the example of V-Ray or similar?

Thanks for your attention)

Hi Yuri -

Being able to capture a “viewport” from a headless Rhino has been on our wishlist for a while.
We’ll need to rewrite our OpenGL code so it works without any windows.
-wim

2 Likes

Hi, Wim!

Yes, I read a lot of topics about this problem on the forum. And what about third-party renderers like V-ray or Blender Cycles. Will they work? V-ray has integration into Rhino, but will it work with this way of using it? Maybe there are some tutorials (within the framework of the described usage algorithm) that I haven’t found?

And I would also like to know how close is the day when the render from a headless Rhino will be released? if it’s not a secret)

We don’t know. It isn’t something we are actively working on as it will probably require a large rewrite of how our display architecture gets up and running. It is something we would like to have internally as well as it would make running some of our testing framework simpler.

I don’t have a decent answer for you with regards to using renderers when headless to generate images. @nathanletwory do we have any SDK routines for generating an image from our renderer when running headless?

1 Like

As far as I know we don’t have a way of starting renders in a headless environment just yet. But I don’t see a reason to not have an API for that. The changequeue takes an ON_3dmView and optionally display pipeline attributes.

We just need a way to run a _Render without having to have a render window visible.

Hi everybody.

It turned out to do the following:

  1. Create a prepared 3dm file in which predefined layers are specified.
  2. We open this file in headless mode.
  3. Then, according to a certain algorithm, we bake the geometry in layers.
  4. Then there are two ways:
    4.1. Export a headless document to OBJ and send the obj file to render in blender via a request to a separate web server. The parameters for the camera are also passed in the request body. At the output, we get the Desired image.
    4.2. Export a headless document to 3dm and send a 3dm file to render in blender via a request to a separate web server. You need to use an additional addon for blender to import 3dm. Both geometry and cameras are imported. But so far it has not been possible to import geometry, the geometry objects themselves are there, but the geometry is invisible. We get an empty image at the output.

Some kind of incorrect algorithm for saving to 3dm, because if you take the original 3dm file (our template), then it is imported into blender normally.

Let’s think about it. Let’s try to import 3dm anyway. If not, we will work with OBJ. Maybe someone had a similar problem?

And it all works through rhino.compute, a grasshopper model using hops, an intermediate bridge server.

I will describe the process in more detail after full configuration.

Thank you all for your help. Especially @wim, @stevebaer, @nathanletwory, @AndyPayne .

What addon do you use for importing the 3dm file into Blender?

edit: if it is import_3dm you need to make sure that your objects have meshes set as well. When you save a file in Rhino with shaded or rendered mode this happens automatically. When you headless you’ll have to ensure that yourself

1 Like