public void Terminate() { Application.Idle -= OnIdle; GhDrawingContext.Terminate(); GrasshopperDataExtension.Terminate(); Rhinoceros.Shutdown(); }
public static void Run(GH_Document definition, GrasshopperData ghData, _BcAp.Document bcDoc) { bool saveState = GH_Document.EnableSolutions; GH_Document.EnableSolutions = true; definition.Enabled = true; var inputs = GetInputParams(definition); var hostEntityId = ghData.HostEntity; foreach (var input in inputs) { if (!IsInputName(input.NickName)) { continue; } if (input is Parameters.BcEntity) { input.ClearData(); var data = new Types.BcEntity(hostEntityId.ToFsp(), bcDoc.Name); input.AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, data); data.LoadGeometry(bcDoc); continue; } var prop = ghData.GetProperty(FormatName(input.NickName)); if (prop == null) { continue; } input.VolatileData.ClearData(); switch (prop) { case int intValue: case double doubleValue: case bool boolValue: case string strValue: input.AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, prop); break; case _OdGe.Point3d pntValue: input.AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, pntValue.ToRhino()); break; case _OdGe.Vector3d vecValue: input.AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, vecValue.ToRhino()); break; } } Rhino.RhinoApp.SetFocusToMainWindow(); definition.NewSolution(false, GH_SolutionMode.Silent); Rhinoceros.Run(); GH_Document.EnableSolutions = saveState; }
public void Initialize() { var editor = Application.DocumentManager.MdiActiveDocument.Editor; if (!Rhinoceros.Startup() || !Rhinoceros.LoadGrasshopperComponents()) { editor.WriteMessage("\nFailed to start Rhino WIP"); return; } var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); editor.WriteMessage($"\nGrasshopper-BricsCAD Connection {version}"); GrasshopperDataExtension = new GhDataExtension(); GrasshopperDataExtension.Initialize(); GhDrawingContext.Initialize(); Application.Idle += OnIdle; }