public SODesigner_Component(string name, string nickname, string description, SODesigner designer) : base(name, nickname, description, GHSustainabilityOpenFramework.CATEGORY, GHSustainabilityOpenFramework.DESIGNER_SUBCATEGORY) { this.m_Designer = designer; SOGrasshopperController con = SOGrasshopperController.GetInstance(OnPingDocument()); }
protected override void SolveInstance(IGH_DataAccess DA) { #if DEBUG Rhino.RhinoApp.WriteLine("Assessment " + this.Name + " is solving"); #endif // check dependencies if (this.m_Assessment == null) { return; } // check if the controller is online SOGrasshopperController con = SOGrasshopperController.GetInstance(OnPingDocument()); List <SODesigner_GHData> designersList = new List <SODesigner_GHData>(); DA.GetDataList <SODesigner_GHData>(0, designersList); this.m_Assessment.ClearDesigners(); foreach (SODesigner_GHData data in designersList) { this.m_Assessment.AddDesigner(data.Value); } List <SOAnalysis_GHData> analysisList = new List <SOAnalysis_GHData>(); DA.GetDataList <SOAnalysis_GHData>(1, analysisList); this.m_Assessment.ClearAnalysis(); foreach (SOAnalysis_GHData data in analysisList) { this.m_Assessment.AddAnalysis(data.Value); } List <SOAssessment_GHData> assessmentsList = new List <SOAssessment_GHData>(); DA.GetDataList <SOAssessment_GHData>(2, assessmentsList); this.m_Assessment.ClearAssessments(); foreach (SOAssessment_GHData data in assessmentsList) { this.m_Assessment.AddAssessment(data.Value); } // run the assessment try { this.m_Assessment.RunAssessment(); } catch (Exception) { return; } SOAssessment_GHData assessment = new SOAssessment_GHData(this.m_Assessment); DA.SetData(0, assessment); }
/// <summary> /// Singleton /// </summary> public static SOGrasshopperController GetInstance(GH.Kernel.GH_Document ghDocument) { #if DEBUG Rhino.RhinoApp.Write("Trying to make controlller... "); #endif if (m_Instance == null) { lock (m_SyncRoot) { if (m_Instance == null) { m_Instance = new SOGrasshopperController(); m_Instance.m_Controller = SOController.Instance; #if DEBUG Rhino.RhinoApp.Write("new... "); #endif } } } #if DEBUG Rhino.RhinoApp.WriteLine("done"); #endif if (ghDocument != null) { if (!m_Instance.m_Registered) { ghDocument.RaiseEvents = true; ghDocument.SolutionStart += new GH.Kernel.GH_Document.SolutionStartEventHandler(ghDocument_SolutionStart); ghDocument.SolutionEnd += new GH.Kernel.GH_Document.SolutionEndEventHandler(ghDocument_SolutionEnd); ghDocument.ObjectsAdded += new GH.Kernel.GH_Document.ObjectsAddedEventHandler(ghDocument_ObjectsAdded); ghDocument.ObjectsDeleted += new GH.Kernel.GH_Document.ObjectsDeletedEventHandler(ghDocument_ObjectsDeleted); m_Instance.m_Registered = true; #if DEBUG Rhino.RhinoApp.WriteLine("Events registered"); #endif } } return(m_Instance); }
/// <summary> /// Singleton /// </summary> public static SOGrasshopperController GetInstance(GH.Kernel.GH_Document ghDocument) { #if DEBUG Rhino.RhinoApp.Write("Trying to make controlller... "); #endif if (m_Instance == null) { lock (m_SyncRoot) { if (m_Instance == null) { m_Instance = new SOGrasshopperController(); m_Instance.m_Controller = SOController.Instance; #if DEBUG Rhino.RhinoApp.Write("new... "); #endif } } } #if DEBUG Rhino.RhinoApp.WriteLine("done"); #endif if (ghDocument != null) { if (!m_Instance.m_Registered) { ghDocument.RaiseEvents = true; ghDocument.SolutionStart += new GH.Kernel.GH_Document.SolutionStartEventHandler(ghDocument_SolutionStart); ghDocument.SolutionEnd += new GH.Kernel.GH_Document.SolutionEndEventHandler(ghDocument_SolutionEnd); ghDocument.ObjectsAdded += new GH.Kernel.GH_Document.ObjectsAddedEventHandler(ghDocument_ObjectsAdded); ghDocument.ObjectsDeleted += new GH.Kernel.GH_Document.ObjectsDeletedEventHandler(ghDocument_ObjectsDeleted); m_Instance.m_Registered = true; #if DEBUG Rhino.RhinoApp.WriteLine("Events registered"); #endif } } return m_Instance; }
protected override void SolveInstance(IGH_DataAccess DA) { #if DEBUG Rhino.RhinoApp.WriteLine("Designer " + this.Name + " is solving"); #endif // check if the controller is online SOGrasshopperController con = SOGrasshopperController.GetInstance(OnPingDocument()); List <SODesigner_GHData> designerList = new List <SODesigner_GHData>(); DA.GetDataList <SODesigner_GHData>(0, designerList); this.m_Designer.ClearDesigners(); foreach (SODesigner_GHData data in designerList) { this.m_Designer.AddDesigner(data.Value); } if (this.m_Designer == null) { return; } try { this.m_Designer.RunDesigner(); } catch (Exception) { return; } // return the designer data SODesigner_GHData data1 = new SODesigner_GHData(this.m_Designer); DA.SetData(0, data1); #if DEBUG Rhino.RhinoApp.WriteLine("> Controller state: " + SOController.Instance.State.ToString()); #endif }