internal static Result Startup() { if (core is null) { // Load RhinoCore try { core = new RhinoCore ( new string[] { "/nosplash", "/notemplate", "/captureprintcalls", "/stopwatch", $"/scheme={SchemeName}", $"/language={Revit.ApplicationUI.ControlledApplication.Language.ToLCID()}" }, WindowStyle.Hidden ); } catch { Addin.CurrentStatus = Addin.Status.Failed; return(Result.Failed); } finally { StartupLog = RhinoApp.CapturedCommandWindowStrings(true); RhinoApp.CommandWindowCaptureEnabled = false; } MainWindow = new WindowHandle(RhinoApp.MainWindowHandle()); External.ActivationGate.AddGateWindow(MainWindow.Handle); RhinoApp.MainLoop += MainLoop; RhinoDoc.NewDocument += OnNewDocument; RhinoDoc.EndOpenDocumentInitialViewUpdate += EndOpenDocumentInitialViewUpdate; Command.BeginCommand += BeginCommand; Command.EndCommand += EndCommand; // Alternative to /runscript= Rhino command line option RunScriptAsync ( script: Environment.GetEnvironmentVariable("RhinoInside_RunScript"), activate: Addin.StartupMode == AddinStartupMode.AtStartup ); // Reset document units UpdateDocumentUnits(RhinoDoc.ActiveDoc); UpdateDocumentUnits(RhinoDoc.ActiveDoc, Revit.ActiveDBDocument); Type[] types = default; try { types = Assembly.GetCallingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types?.Where(x => x is object).ToArray(); } // Look for Guests guests = types. Where(x => typeof(IGuest).IsAssignableFrom(x)). Where(x => !x.IsInterface). Select(x => new GuestInfo(x)). ToList(); CheckInGuests(); //Enable Revit window back WindowHandle.ActiveWindow = Revit.MainWindow; } return(Result.Succeeded); }
internal static Result Startup() { if (core is null) { // Load RhinoCore try { core = new RhinoCore ( new string[] { "/nosplash", "/notemplate", "/captureprintcalls", "/stopwatch", $"/scheme={SchemeName}", $"/language={Revit.ApplicationUI.ControlledApplication.Language.ToLCID()}" }, WindowStyle.Hidden ); } catch { Addin.CurrentStatus = Addin.Status.Failed; return(Result.Failed); } finally { StartupLog = RhinoApp.CapturedCommandWindowStrings(true); RhinoApp.CommandWindowCaptureEnabled = false; } MainWindow = new WindowHandle(RhinoApp.MainWindowHandle()); External.ActivationGate.AddGateWindow(MainWindow.Handle); RhinoApp.MainLoop += MainLoop; RhinoDoc.NewDocument += OnNewDocument; RhinoDoc.EndOpenDocumentInitialViewUpdate += EndOpenDocumentInitialViewUpdate; Command.BeginCommand += BeginCommand; Command.EndCommand += EndCommand; // Alternative to /runscript= Rhino command line option RunScriptAsync ( script: Environment.GetEnvironmentVariable("RhinoInside_RunScript"), activate: Addin.StartupMode == AddinStartupMode.AtStartup ); // Add DefaultRenderAppearancePath to Rhino settings if missing { var DefaultRenderAppearancePath = System.IO.Path.Combine ( Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFilesX86), "Autodesk Shared", "Materials", "Textures" ); if (!Rhino.ApplicationSettings.FileSettings.GetSearchPaths().Any(x => x.Equals(DefaultRenderAppearancePath, StringComparison.InvariantCultureIgnoreCase))) { Rhino.ApplicationSettings.FileSettings.AddSearchPath(DefaultRenderAppearancePath, -1); } // TODO: Add also AdditionalRenderAppearancePaths content from Revit.ini if missing ?? } // Reset document units UpdateDocumentUnits(RhinoDoc.ActiveDoc); UpdateDocumentUnits(RhinoDoc.ActiveDoc, Revit.ActiveDBDocument); Type[] types = default; try { types = Assembly.GetCallingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types?.Where(x => x is object).ToArray(); } // Look for Guests guests = types. Where(x => typeof(IGuest).IsAssignableFrom(x)). Where(x => !x.IsInterface && !x.IsAbstract && !x.ContainsGenericParameters). Select(x => new GuestInfo(x)). ToList(); CheckInGuests(); } return(Result.Succeeded); }