private void Iterate() { int i = 1; foreach (List <double> sample in MyComponent.DesignMap) { GHUtilities.ChangeSliders(MyComponent.SlidersList, sample); // If we're taking screen shots, this happens here. if (MyComponent.Mode == CaptureComponent.CaptureMode.SaveScreenshot || MyComponent.Mode == CaptureComponent.CaptureMode.Both) { BeforeScreenShots(); ScreenShot(i); AfterScreenShots(); MyComponent.ImagesWritten = "Yes"; } i++; } // If we're saving a CSV, this happens here. if (MyComponent.Mode == CaptureComponent.CaptureMode.SaveCSV || MyComponent.Mode == CaptureComponent.CaptureMode.Both) { WriteOutputToFile(MyComponent.AssembleDMO(MyComponent.DesignMap, MyComponent.ObjValues), MyComponent.CSVDir, MyComponent.CSVFilename, ".csv"); MyComponent.DataWritten = "Yes"; } }
private void Iterate() { int i = 1; MyComponent.Index = i; foreach (List <double> sample in MyComponent.DesignMap) { GHUtilities.ChangeSliders(MyComponent.SlidersList, sample); MyComponent.Index = i; // If we're taking screen shots, this happens here. if (MyComponent.Mode == CaptureComponent.CaptureMode.SaveScreenshot || MyComponent.Mode == CaptureComponent.CaptureMode.Both) { if (MyComponent.SSDir == "None") { throw new Exception("No screenshot directory given! Please add valid directory"); } BeforeScreenShots(); ScreenShot(i); AfterScreenShots(); MyComponent.ImagesWritten = "Yes"; } // Write intermediate Screenshots if (MyComponent.Mode == CaptureComponent.CaptureMode.SaveCSV || MyComponent.Mode == CaptureComponent.CaptureMode.Both) { if (MyComponent.SaveFreq > 0) { if (i % MyComponent.SaveFreq == 0) { WriteProgressToFile(MyComponent.AssembleDMO(MyComponent.DesignMap, MyComponent.ObjValues), MyComponent.CSVDir, MyComponent.CSVFilename, ".csv", i); int Last = i - MyComponent.SaveFreq; System.IO.File.Delete(MyComponent.CSVDir + MyComponent.CSVFilename + "_progress_" + Last.ToString() + ".csv"); } } } i++; } // If we're saving a CSV, this happens here. if (MyComponent.Mode == CaptureComponent.CaptureMode.SaveCSV || MyComponent.Mode == CaptureComponent.CaptureMode.Both) { WriteOutputToFile(MyComponent.AssembleDMO(MyComponent.DesignMap, MyComponent.ObjValues), MyComponent.CSVDir, MyComponent.CSVFilename, ".csv"); MyComponent.DataWritten = "Yes"; if (MyComponent.CSVDir == "None") { throw new Exception("No CSV directory given! Please add valid directory"); } } }
private void Iterate() { int i = 1; foreach (List <double> sample in this.DesignMapEffects) { GHUtilities.ChangeSliders(MyComponent.SlidersList, sample); i++; } }
private void Iterate() { int i = 1; foreach (List <double> sample in this.DesignMapEffects) { GHUtilities.ChangeSliders(MyComponent.SlidersList, sample); // If we're taking screen shots, this happens here. i++; } }
private void Iterate() { int i = 1; foreach (List <double> sample in this.DesignMapStepperCombined) { GHUtilities.ChangeSliders(MyComponent.SlidersList, sample); // Reset last slider if (i == this.DesignMapStepperCombined.Count) { } i++; } }
public override Grasshopper.GUI.Canvas.GH_ObjectResponse RespondToMouseDoubleClick(Grasshopper.GUI.Canvas.GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e) { if (MyComponent.Seed != 0) { MyComponent.MyRand = new Random(MyComponent.Seed); } // reset Random to give same result each time. MyComponent.Util.Sample(); if (MyComponent.Dir != "None") { GHUtilities.WriteOutputToFile(MyComponent.Output, MyComponent.Dir, MyComponent.Filename, ".csv"); MyComponent.FilesWritten = "Yes"; } Grasshopper.Instances.ActiveCanvas.Document.NewSolution(true); return(base.RespondToMouseDoubleClick(sender, e)); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { readSlidersList(); // First, we need to retrieve all data from the input parameters. // We'll start by declaring variables and assigning them starting values. // Then we need to access the input parameters individually. // When data cannot be extracted from required parameters, abort this method if (!DA.GetData(1, ref NSamples)) { return; } if (!DA.GetData(2, ref Scheme)) { return; } if (!DA.GetData(3, ref Seed)) { return; } // if (!DA.GetData(4, ref Filename)) return; // if (!DA.GetData(5, ref Dir)) return; DA.GetData(4, ref Filename); DA.GetData(5, ref Dir); // Make sure there is backslash on directory char last = Dir[Dir.Length - 1]; if (!last.Equals('\\') && Dir != "None") { Dir = @Dir + @"\"; } // We should now validate the data and warn the user if invalid data is supplied. DA.SetDataTree(0, GHUtilities.ListOfListsToTree <double>(this.Output)); DA.SetData(1, FilesWritten); }
public override Grasshopper.GUI.Canvas.GH_ObjectResponse RespondToMouseDoubleClick(Grasshopper.GUI.Canvas.GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e) { GHUtilities.ChangeSliders(MyComponent.SlidersList, MyComponent.DesignMap[MyComponent.Index]); Grasshopper.Instances.ActiveCanvas.Document.NewSolution(true); return(base.RespondToMouseDoubleClick(sender, e)); }