Grasshopper

algorithmic modeling for Rhino

Hi,

I would like to know if there would be a way to stream the pixels informatin of "what a Rhino camera is seeing". I would like change the camera with Horster and send those pixels to other application.

I reckon that if we could get to save an image with viewcapturetofile we could get that information in real time? And what if the camera was not the active one?

I hope I made myself clear.

Any help would be really appreciated!

Many thanks

Views: 545

Replies to This Discussion

There's the capturetobitmap method on the rhinoview class, that should get you going.

http://4.rhino3d.com/5/rhinocommon/html/Overload_Rhino_Display_Rhin...

You can get any view (it has to be enabled though, otherwise there's no drawing going on in the viewport.)

I'm not sure if this is really a good way to stream at a reasonable rate. In my experience the method is not extremely fast, and tends to interfere with the UI.

Hi Arend,

Many thanks for your feply.

I tried implementing the capturetobitmap method but I did not manage to make it work.

 

Is it in the Rhino.Display.RhinoView class? My script component did not lead me there.

 

I tried something like this:

 

    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(800, 600);

    bmp = Rhino.Display.RhinoView.CaptureToBitmap();

 

Could you please give me any hint on this?

 

Thanks for your help in advance

Ah, check. It's not a static method. You need to get the actual viewport, using the name of the viewport, e.g.:

Rhino.Display.RhinoView view = RhinoDocument.Views.Find("perspective", false);

using (System.Drawing.Bitmap bmp = System.Drawing.Bitmap)

{

   // do stuff with the bmp here

}

you will need to use the using statement to avoid memory leaks (if you don't call dispose on the bitmap, there's a change it will remain in memory, and you increase the chance of memory leaks).

See: http://stackoverflow.com/questions/567138/when-should-i-use-using-b...

http://msdn.microsoft.com/en-us/library/yh598w02.aspx

Hi Arend,

Sorry for the late reply.

 

This has been really useful!

 

Many thanks

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service