Esempio n. 1
0
        static bool OnSave(int serial_number, IntPtr filename, IntPtr content_ptr, IntPtr scene_server_ptr)
        {
            try
            {
                IOPlugIn      io      = IOPlugIn.FromSerialNumber(serial_number) as IOPlugIn;
                RenderContent content = RenderContent.FromPointer(content_ptr);

                CreatePreviewEventArgs pc = null;

                if (scene_server_ptr != IntPtr.Zero)
                {
                    pc = new CreatePreviewEventArgs(scene_server_ptr, new System.Drawing.Size(100, 100), PreviewSceneQuality.RefineThirdPass);
                }

                if (io != null && content != null)
                {
                    string _filename = Marshal.PtrToStringUni(filename);
                    return(io.Save(_filename, content, pc));
                }
            }
            catch
            {
            }
            return(false);
        }
Esempio n. 2
0
 static void OnDeleteThis(int serial_number)
 {
     try
     {
         IOPlugIn io = IOPlugIn.FromSerialNumber(serial_number) as IOPlugIn;
         if (io != null)
         {
             io.Destroy();
         }
     }
     catch
     {
     }
 }
Esempio n. 3
0
 static void OnGetRenderContentIoString(int serial_number, bool local, IntPtr pON_wString)
 {
     try
     {
         IOPlugIn io = IOPlugIn.FromSerialNumber(serial_number) as IOPlugIn;
         if (io != null)
         {
             string str = local ? io.LocalDescription : io.EnglishDescription;
             if (!string.IsNullOrEmpty(str))
             {
                 UnsafeNativeMethods.ON_wString_Set(pON_wString, str);
             }
         }
     }
     catch (Exception ex)
     {
         Rhino.Runtime.HostUtils.ExceptionReport(ex);
     }
 }
Esempio n. 4
0
 static int OnLoad(int serial_number, IntPtr filename)
 {
     try
     {
         IOPlugIn io = IOPlugIn.FromSerialNumber(serial_number) as IOPlugIn;
         if (io != null)
         {
             string        _filename = Marshal.PtrToStringUni(filename);
             RenderContent content   = io.Load(_filename);
             if (content != null)
             {
                 return(content.m_runtime_serial_number);
             }
         }
     }
     catch
     {
     }
     return(0);
 }
Esempio n. 5
0
        public static Type[] RegisterContentIo(System.Reflection.Assembly assembly, System.Guid pluginId)
        {
            Rhino.PlugIns.PlugIn plugin = Rhino.PlugIns.PlugIn.GetLoadedPlugIn(pluginId);
            if (plugin == null)
            {
                return(null);
            }

            //Find all public types exported in the plug-in that we're dealing with
            Type[] exported_types = assembly.GetExportedTypes();
            if (exported_types != null)
            {
                List <Type> contentio_types = new List <Type>();
                for (int i = 0; i < exported_types.Length; i++)
                {
                    //If the type is a Render.IOPlugIn, add it to the "to register" list.
                    Type t = exported_types[i];
                    if (!t.IsAbstract && t.IsSubclassOf(typeof(Rhino.Render.IOPlugIn)) && t.GetConstructor(new Type[] { }) != null)
                    {
                        contentio_types.Add(t);
                    }
                }

                // make sure that content types have not already been registered
                for (int i = 0; i < contentio_types.Count; i++)
                {
                    Type t = contentio_types[i];

                    if (!RdkPlugIn.RenderContentIoTypeIsRegistered(t))
                    {
                        //The object registers itself in a static array
                        IOPlugIn pi = System.Activator.CreateInstance(t) as IOPlugIn;
                        pi.Construct(pluginId);
                    }
                }

                return(contentio_types.ToArray());
            }
            return(null);
        }