Create preview images with Rhino.Inside and a third party plugin

Hi,

this time i have a complicated one. We try to automate the generation of preview images of our 3dm files. In the background there happens much more, but to brake it down to the essential part i do following:

For the preview image we use this code rhino-developer-samples/cmdSampleViewCapturePenMode.cpp at 7 · mcneel/rhino-developer-samples · GitHub (but without dialog interaction)

For the automation we created a small Rhino.Inside application which calls the command from the example above like this:

namespace Convert
{
    class Program
    {
        #region Program static constructor
        static Program()
        {
            RhinoInside.Resolver.Initialize();
        }
        #endregion

         // Use STAThread for this app as we are starting Rhino in a mode that does actually
        // include user interface (we just never show the main window). This allows for things
        // like RhinoApp().RunScript to properly run.
        [System.STAThread]
        static int Main(string[] args)
        {
            try
            {
                using (new RhinoCore(new string[] { "/NOSPLASH" }, WindowStyle.Hidden))
                {
                    if (RhinoApp.RunScript("_-SampleViewCapturePenMode _Enter", false))
                    {
                        return 0;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            return 1;
        }
    }
}

Now if i start it interactively it works perfect but when i start it as a windows service it crashes at the line with “rpi.DrawToSingleDib”

The reason why we do it like this is, as i already mentioned, there happens much more in the background which would be too much to port it to c# Rhino.Inside. So that’s the reason why we only start the command in c#.

Any ideas about that?
Thanks

Hi @dsw,

I believe for any of the “view” or “screen” capture stuff to work Rhino must be visible so that OpenGL is initialized and operational. Does showing the Rhino main window help?

– Dale

Hi @dale,

no, it does not make any difference. So i think the OpenGL initialization is omitted if i run Rhino.Inside as a service, isn’t it?

Which leads me to the question: What is your suggested way to create automated preview images with Rhino.Inside (within a windows service)?

Thanks
Wolfgang