public static Rhino.Commands.Result ShowSurfaceDirection(Rhino.RhinoDoc doc) { Rhino.DocObjects.ObjRef objref; var rc = Rhino.Input.RhinoGet.GetOneObject("Select surface or polysurface for direction display", false, Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.PolysrfFilter, out objref); if (rc != Rhino.Commands.Result.Success) { return(rc); } var brep = objref.Brep(); if (brep == null) { return(Rhino.Commands.Result.Failure); } bool bIsSolid = brep.IsSolid; TestSurfaceDirConduit conduit = new TestSurfaceDirConduit(brep); conduit.Enabled = true; doc.Views.Redraw(); var gf = new Rhino.Input.Custom.GetOption(); gf.SetCommandPrompt("Press enter when done"); gf.AcceptNothing(true); if (!bIsSolid) { gf.AddOption("Flip"); } for (; ;) { var res = gf.Get(); if (res == Rhino.Input.GetResult.Option) { conduit.Flip = !conduit.Flip; doc.Views.Redraw(); continue; } if (res == Rhino.Input.GetResult.Nothing) { if (!bIsSolid && conduit.Flip) { brep.Flip(); doc.Objects.Replace(objref, brep); } } break; } conduit.Enabled = false; doc.Views.Redraw(); return(Rhino.Commands.Result.Success); }
protected override GH_GetterResult Prompt_Singular(ref IGH_Goo value) { Rhino.Input.Custom.GetPoint gpC = new Rhino.Input.Custom.GetPoint(); gpC.SetCommandPrompt("Set default tool center point."); gpC.AcceptNothing(true); Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption(); go.SetCommandPrompt("Set default tool."); go.AcceptNothing(true); go.AddOption("True"); switch (go.Get()) { case Rhino.Input.GetResult.Option: if (go.Option().EnglishName == "True") { value = ABBTool.Default; } return(GH_GetterResult.success); case Rhino.Input.GetResult.Nothing: return(GH_GetterResult.accept); default: return(GH_GetterResult.cancel); } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Rhino.Display.RhinoView view = doc.Views.ActiveView; if (null == view) { return(Result.Failure); } Rhino.Display.RhinoViewport viewport = view.ActiveViewport; Rhino.Display.DisplayModeDescription currentDisplayMode = viewport.DisplayMode; Rhino.RhinoApp.WriteLine("Viewport in {0} display.", currentDisplayMode.EnglishName); Rhino.Display.DisplayModeDescription[] displayModes = Rhino.Display.DisplayModeDescription.GetDisplayModes(); Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption(); go.SetCommandPrompt("Select new display mode"); go.AcceptNothing(true); foreach (Rhino.Display.DisplayModeDescription displayMode in displayModes) { string displayName = FormatValidDisplayName(displayMode.EnglishName); go.AddOption(displayName); } Rhino.Input.GetResult rc = go.Get(); switch (rc) { case Rhino.Input.GetResult.Option: { int optionIndex = go.Option().Index; if (optionIndex > 0 && optionIndex <= displayModes.Length) { Rhino.Display.DisplayModeDescription newDisplayMode = displayModes[optionIndex - 1]; if (newDisplayMode.Id != currentDisplayMode.Id) { viewport.DisplayMode = newDisplayMode; view.Redraw(); Rhino.RhinoApp.WriteLine("Viewport set to {0} display.", viewport.DisplayMode.EnglishName); } } } break; case Rhino.Input.GetResult.Cancel: return(Result.Cancel); default: break; } return(Result.Success); }
protected override GH_GetterResult Prompt_Singular(ref GH_Integer value) { Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption(); go.SetCommandPrompt("Set default motion type."); go.AcceptNothing(true); go.AddOption("True"); switch (go.Get()) { case Rhino.Input.GetResult.Option: if (go.Option().EnglishName == "True") { value = new GH_Integer((int)MotionType.Linear); } return(GH_GetterResult.success); case Rhino.Input.GetResult.Nothing: return(GH_GetterResult.accept); default: return(GH_GetterResult.cancel); } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Pick some objects to smooth Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject(); go.SetCommandPrompt("Select objects to smooth"); go.SubObjectSelect = false; go.ReferenceObjectSelect = false; go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve | Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.Mesh; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } // Prompt for some command line options. In this case, // we will clone the -Smooth command. Rhino.Input.Custom.GetOption gs = new Rhino.Input.Custom.GetOption(); gs.SetCommandPrompt("Choose smooth option"); gs.AcceptNothing(true); for (; ;) { gs.ClearCommandOptions(); Rhino.Input.Custom.OptionDouble smooth_factor_option = new Rhino.Input.Custom.OptionDouble(m_smooth_factor); Rhino.Input.Custom.OptionToggle use_cplane_option = new Rhino.Input.Custom.OptionToggle(m_use_cplane, "World", "CPlane"); Rhino.Input.Custom.OptionToggle smooth_x_option = new Rhino.Input.Custom.OptionToggle(m_smooth_x, "No", "Yes"); Rhino.Input.Custom.OptionToggle smooth_y_option = new Rhino.Input.Custom.OptionToggle(m_smooth_y, "No", "Yes"); Rhino.Input.Custom.OptionToggle smooth_z_option = new Rhino.Input.Custom.OptionToggle(m_smooth_z, "No", "Yes"); Rhino.Input.Custom.OptionToggle fix_boundaries_option = new Rhino.Input.Custom.OptionToggle(m_fix_boundaries, "No", "Yes"); int smooth_factor_index = gs.AddOptionDouble("SmoothFactor", ref smooth_factor_option); int use_cplane_index = gs.AddOptionToggle("CoordinateSystem", ref use_cplane_option); int smooth_x_index = gs.AddOptionToggle("X", ref smooth_x_option); int smooth_y_index = gs.AddOptionToggle("Y", ref smooth_y_option); int smooth_z_index = gs.AddOptionToggle("Z", ref smooth_z_option); int fix_boundaries_index = gs.AddOptionToggle("FixBoundaries", ref fix_boundaries_option); Rhino.Input.GetResult getrc = gs.Get(); if (gs.CommandResult() != Result.Success) { return(gs.CommandResult()); } if (getrc == Rhino.Input.GetResult.Option) { int index = gs.OptionIndex(); if (index == smooth_factor_index) { m_smooth_factor = smooth_factor_option.CurrentValue; } else if (index == use_cplane_index) { m_use_cplane = use_cplane_option.CurrentValue; } else if (index == smooth_x_index) { m_smooth_x = smooth_x_option.CurrentValue; } else if (index == smooth_y_index) { m_smooth_y = smooth_y_option.CurrentValue; } else if (index == smooth_z_index) { m_smooth_z = smooth_z_option.CurrentValue; } else if (index == fix_boundaries_index) { m_fix_boundaries = fix_boundaries_option.CurrentValue; } continue; } break; } // Build a command line macro that we can script StringBuilder sb = new StringBuilder(); sb.Append("_-Smooth "); sb.Append(string.Format("_SmoothFactor={0} ", m_smooth_factor)); sb.Append(string.Format("_CoordinateSystem={0} ", m_use_cplane ? "_CPlane" : "_World")); sb.Append(string.Format("_X={0} ", m_smooth_x ? "_Yes" : "_No")); sb.Append(string.Format("_Y={0} ", m_smooth_y ? "_Yes" : "_No")); sb.Append(string.Format("_Z={0} ", m_smooth_z ? "_Yes" : "_No")); sb.Append(string.Format("_FixBoundaries={0} ", m_fix_boundaries ? "_Yes" : "_No")); sb.Append("_Enter"); string script = sb.ToString(); #if (!RELEASE) Rhino.RhinoApp.WriteLine(script); #endif // Script the smooth command Rhino.RhinoApp.RunScript(script, false); return(Result.Success); }
///<summary> This gets called when when the user runs this command.</summary> protected override Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode) { SourceConduit m_source_conduit = SourceConduit.Instance; Rhino.Input.Custom.GetObject GO = new Rhino.Input.Custom.GetObject(); GO.SetCommandPrompt("Select source curve..."); GO.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; GO.AddOption("TrafficWelsh"); GO.AddOption("TrafficFHWA"); GO.AddOption("AircraftANCON"); GO.AddOption("Custom"); //GO.AddOptionList("SourceType", new List<string>() { "TrafficWelshStandard", "TrafficFHWA Standard", "Custom" }, 2); GO.GroupSelect = false; GO.SubObjectSelect = false; GO.EnableClearObjectsOnEntry(false); GO.EnableUnselectObjectsOnExit(false); GO.DeselectAllBeforePostSelect = false; int pavement = 0; double SPLW = 0; double[] SWL = new double[] { 120, 120, 120, 120, 120, 120, 120, 120 }; double velocity = 83; double delta = 45; double choice = 0; for (; ; ) { Rhino.Input.GetResult GR = GO.GetMultiple(1, 1); int type = GO.OptionIndex(); if (GR == Rhino.Input.GetResult.Option) { choice = (int)type; //type = GO.Option().EnglishName; if (type == 1)//"Traffic (Welsh Standard)") { Rhino.Input.RhinoGet.GetNumber("Input basis road sound pressure level at 1 m from street...", false, ref SPLW); SPLW += 8; } else if (type == 2)//"Traffic (FHWA Standard)") { ///Described at: ///http://www.fhwa.dot.gov/environment/noise/traffic_noise_model/old_versions/tnm_version_10/tech_manual/tnm03.cfm#tnma2 double s = 0; //int i = 0; Rhino.Input.RhinoGet.GetNumber("Enter the speed of traffic on this road (in kph)...", false, ref s); ///Pavement Rhino.Input.Custom.GetOption GOpt = new Rhino.Input.Custom.GetOption(); GOpt.SetCommandPrompt("Pavement type..."); GOpt.AddOption("Average_DGAC_PCC)"); GOpt.AddOption("DGAC_Asphalt"); GOpt.AddOption("PCC_Concrete"); GOpt.AddOption("OGAC_OpenGradedAsphalt"); GOpt.AcceptNothing(false); GOpt.Get(); pavement = GOpt.OptionIndex(); ///Vehicle tallies double[] Veh = new double[5] { 0, 0, 0, 0, 0 }; Rhino.Input.RhinoGet.GetNumber("Enter the number of automobiles per hour...", false, ref Veh[0]); Rhino.Input.RhinoGet.GetNumber("Enter the number of medium trucks per hour...", false, ref Veh[1]); Rhino.Input.RhinoGet.GetNumber("Enter the number of heavy trucks per hour...", false, ref Veh[2]); Rhino.Input.RhinoGet.GetNumber("Enter the number of buses per hour...", false, ref Veh[3]); Rhino.Input.RhinoGet.GetNumber("Enter the number of motorcycles per hour...", false, ref Veh[4]); bool throttle = false; int t = 0; Rhino.Input.RhinoGet.GetBool("Full throttle?", false, "Yes", "No", ref throttle); t = (throttle) ? 1 : 0; double root2 = Math.Sqrt(2); double vtot = 0; double[] Es = new double[8] { 0, 0, 0, 0, 0, 0, 0, 0 }; for (int v = 0; v < 5; v++) { double A = FHWATraffic[v][pavement][t][0]; double B = FHWATraffic[v][pavement][t][1]; double C = FHWATraffic[v][pavement][t][2]; double D1 = FHWATraffic[v][pavement][t][3]; double D2 = FHWATraffic[v][pavement][t][4]; double E1 = FHWATraffic[v][pavement][t][5]; double E2 = FHWATraffic[v][pavement][t][6]; double F1 = FHWATraffic[v][pavement][t][7]; double F2 = FHWATraffic[v][pavement][t][8]; double G1 = FHWATraffic[v][pavement][t][9]; double G2 = FHWATraffic[v][pavement][t][10]; double H1 = FHWATraffic[v][pavement][t][11]; double H2 = FHWATraffic[v][pavement][t][12]; double I1 = FHWATraffic[v][pavement][t][13]; double I2 = FHWATraffic[v][pavement][t][14]; double J1 = FHWATraffic[v][pavement][t][15]; double J2 = FHWATraffic[v][pavement][t][16]; vtot += Veh[v]; for (int oct = 0; oct < 8; oct++) { double f = 62.5 * Math.Pow(2, oct); double[] freq = new double[3] { f / root2, f, f * root2 }; for (int oct3 = 0; oct3 < 3; oct3++) { double Ea = Math.Pow(0.6214 * s, A / 10) * Math.Pow(10, B / 10) + Math.Pow(10, C / 10); double logf = Math.Log10(freq[oct3]); double Ls = 10 * Math.Log10(Ea) + (D1 + 0.6214 * D2 * s) + (E1 + 0.6214 * E2 * s) * logf + (F1 + 0.6214 * F2 * s) * logf * logf + (G1 + 0.6214 * G2 * s) * logf * logf * logf + (H1 + 0.6214 * H2 * s) * logf * logf * logf * logf + (I1 + 0.6214 * I2 * s) * logf * logf * logf * logf * logf + (J1 + 0.6214 * J2 * s) * logf * logf * logf * logf * logf * logf; Es[oct] += 0.0476 * Math.Pow(10, Ls / 10) * Veh[v] / s; } } } double[] Awt = new double[8] { -26, -16, -9, -3, 0, 1.2, 1, -1 }; double dmod = 10 * Math.Log10(1 / (Utilities.Numerics.PiX2 * 15)); for (int oct = 0; oct < 8; oct++) { SWL[oct] = 10 * Math.Log10(Es[oct]) - Awt[oct] - dmod;// } } else if (type == 3)//"Aircraft (ANCON-derived)") { Rhino.Input.Custom.GetOption GOpt = new Rhino.Input.Custom.GetOption(); GOpt.SetCommandPrompt("Takeoff or Landing?"); GOpt.AddOption("Takeoff"); GOpt.AddOption("Landing"); GOpt.AddOption("Both"); GOpt.AcceptNothing(false); GOpt.Get(); int TL_Choice = GOpt.OptionIndex(); double SWLA = 150; Rhino.Input.RhinoGet.GetNumber("What is the broadband sound power of the aircraft (in dBA)?", false, ref SWLA); Rhino.Input.RhinoGet.GetNumber("What is the maximum velocity of the aircraft in m/s?", false, ref velocity); Rhino.Input.RhinoGet.GetNumber("What is the slant angle for this aircraft?", false, ref delta); double[][] Aircraft_Normalization = new double[3][] { //new double[8]{ -12, -10.5, -12, -15, -20, -27, -40, -44}, //new double[8]{-11, -13, -12, -13.5, -18, -21, -25, -35}, //new double[8]{-11, -10.5, -12, -13.5, -18, -21, -25, -35} new double[8] { 6.191472203, 7.691472203, 6.191472203, 3.191472203, -1.808527797, -8.808527797,-21.8085278, -25.8085278}, new double[8] { 5.6783811710, 3.6783811710, 4.678381171, 3.178381171, -1.321618829, -4.321618829, -8.321618829, -18.32161883}, new double[8] { 5.678381171, 6.178381171, 4.678381171, 3.178381171, -1.321618829, -4.321618829, -8.321618829, -18.32161883} }; for (int oct = 0; oct < 8; oct++) { SWL[oct] = SWLA + Aircraft_Normalization[TL_Choice-1][oct];// } } // continue; // //return Result.Success; //} } else if (GR == Rhino.Input.GetResult.Object) { for (int i = 0; i < GO.ObjectCount; i++) { Rhino.DocObjects.ObjRef obj = GO.Object(i); Rhino.DocObjects.RhinoObject rhObj = doc.Objects.Find(obj.ObjectId); rhObj.Attributes.Name = "Acoustical Source"; if (choice == 1)//"Traffic (Welsh Standard)") { rhObj.Geometry.SetUserString("SourceType", "Traffic (Welsh)"); for (int oct = 0; oct < 8; oct++) SWL[oct] = SPLW + WelshTraffic[oct]; } else if (choice == 2)//"Traffic (FWHA Standard)") { rhObj.Geometry.SetUserString("SourceType", "Traffic (FHWA)"); } else if (choice == 3)//"Aircraft (ANCON-derived)") { rhObj.Geometry.SetUserString("SourceType", "Aircraft (ANCON derived)"); rhObj.Geometry.SetUserString("Velocity", velocity.ToString()); rhObj.Geometry.SetUserString("delta", delta.ToString()); } else { Rhino.Input.RhinoGet.GetNumber("62.5 Hz. Sound Power Level", true, ref SWL[0]); Rhino.Input.RhinoGet.GetNumber("125 Hz. Sound Power Level", true, ref SWL[1]); Rhino.Input.RhinoGet.GetNumber("250 Hz. Sound Power Level", true, ref SWL[2]); Rhino.Input.RhinoGet.GetNumber("500 Hz. Sound Power Level", true, ref SWL[3]); Rhino.Input.RhinoGet.GetNumber("1000 Hz. Sound Power Level", true, ref SWL[4]); Rhino.Input.RhinoGet.GetNumber("2000 Hz. Sound Power Level", true, ref SWL[5]); Rhino.Input.RhinoGet.GetNumber("4000 Hz. Sound Power Level", true, ref SWL[6]); Rhino.Input.RhinoGet.GetNumber("8000 Hz. Sound Power Level", true, ref SWL[7]); } rhObj.Geometry.SetUserString("SWL", Utilities.PachTools.EncodeSourcePower(SWL)); rhObj.Geometry.SetUserString("Phase", "0;0;0;0;0;0;0;0"); doc.Objects.ModifyAttributes(rhObj, rhObj.Attributes, true); m_source_conduit.SetSource(rhObj); } doc.Views.Redraw(); return Result.Success; } else return Result.Cancel; } }
///<summary> This gets called when when the user runs this command.</summary> protected override Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode) { SourceConduit m_source_conduit = SourceConduit.Instance; Rhino.Geometry.Point3d Pt; Rhino.Input.RhinoGet.GetPoint("Select Location of speaker's mouth...", false, out Pt); Rhino.Input.Custom.GetOption GOpt_type = new Rhino.Input.Custom.GetOption(); Rhino.Input.Custom.GetOption GOpt_act = new Rhino.Input.Custom.GetOption(); GOpt_type.SetCommandPrompt("Pick what kind of speaker this is..."); GOpt_type.AddOption("Man"); GOpt_type.AddOption("Woman"); GOpt_type.AddOption("Child"); GOpt_type.AcceptNothing(false); GOpt_type.Get(); Rhino.Input.Custom.GetOption GOpt = new Rhino.Input.Custom.GetOption(); GOpt_act.SetCommandPrompt("Pick the best descriptor of vocal effort..."); GOpt_act.AddOption("SoftOrWhispered"); GOpt_act.AddOption("Conversation"); GOpt_act.AddOption("CompetingConversation"); GOpt_act.AddOption("Singing"); GOpt_act.AddOption("Shouting"); GOpt_act.AcceptNothing(false); GOpt_act.Get(); double[] SPL = new double[0]; switch (GOpt_type.OptionIndex()) { case 0: SPL = Males[GOpt_act.OptionIndex()-1]; break; case 1: SPL = Females[GOpt_act.OptionIndex()-1]; break; case 2: SPL = Children[GOpt_act.OptionIndex()-1]; break; } Rhino.DocObjects.RhinoObject rhObj = doc.Objects.Find(doc.Objects.AddPoint(Pt)); rhObj.Attributes.Name = "Acoustical Source"; rhObj.Geometry.SetUserString("SourceType", "0"); for (int i = 0; i < 8; i++) SPL[i] += 11; rhObj.Geometry.SetUserString("SWL", Utilities.PachTools.EncodeSourcePower(SPL)); rhObj.Geometry.SetUserString("Phase", "0;0;0;0;0;0;0;0"); doc.Objects.ModifyAttributes(rhObj, rhObj.Attributes, true); m_source_conduit.SetSource(rhObj); doc.Views.Redraw(); Rhino.RhinoApp.WriteLine("Apologies, but at this time, human sources are treated as omnidirectional, which is great if you are trying to "); Rhino.RhinoApp.WriteLine("characterize speech, but not so good if you are trying to simulate an exact individual in the act of speaking..."); Rhino.RhinoApp.WriteLine("If you happen to know of a good database with human speech directivity, or would otherwise like to contribute, please let me know. --Arthur"); return Result.Success; }
///<summary> This gets called when when the user runs this command.</summary> protected override Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode) { SourceConduit m_source_conduit = SourceConduit.Instance; //Rhino.DocObjects.ObjRef location; string type = "custom"; Rhino.Input.Custom.GetObject GO = new Rhino.Input.Custom.GetObject(); GO.SetCommandPrompt("Select source surface..."); GO.GeometryFilter = Rhino.DocObjects.ObjectType.Brep; GO.AddOption("Crowd"); GO.GroupSelect = false; GO.SubObjectSelect = false; GO.EnableClearObjectsOnEntry(false); GO.EnableUnselectObjectsOnExit(false); GO.DeselectAllBeforePostSelect = false; int Men = 100, Women = 100, Kids = 100, effort = 0; do { Rhino.Input.GetResult GR = GO.Get(); if (GR == Rhino.Input.GetResult.Option) { type = GO.Option().EnglishName; if (type == "Crowd") { Rhino.Input.RhinoGet.GetInteger("Number of Men in Crowd...", true, ref Men); Rhino.Input.RhinoGet.GetInteger("Number of Women in Crowd...", true, ref Women); Rhino.Input.RhinoGet.GetInteger("Number of Children in Crowd...", true, ref Kids); Rhino.Input.Custom.GetOption GOpt = new Rhino.Input.Custom.GetOption(); GOpt.SetCommandPrompt("Speech Activity"); GOpt.AddOption("SoftOrWhispered"); GOpt.AddOption("Conversation"); GOpt.AddOption("CompetingConversation"); GOpt.AddOption("Singing"); GOpt.AddOption("AllShouting"); GOpt.AcceptNothing(false); GOpt.Get(); effort = GOpt.OptionIndex() - 1; } continue; } else if (GR == Rhino.Input.GetResult.Object) { for (int i = 0; i < GO.ObjectCount; i++) { Rhino.DocObjects.ObjRef obj = GO.Object(i); Rhino.DocObjects.RhinoObject rhObj = doc.Objects.Find(obj.ObjectId); double Area = (rhObj.Geometry as Rhino.Geometry.Brep).GetArea(); rhObj.Attributes.Name = "Acoustical Source"; rhObj.Geometry.SetUserString("SourceType", ""); double[] SPL = new double[] { 120, 120, 120, 120, 120, 120, 120, 120 }; if (type == "Crowd") { //double mod = (effort < 3) ? .5 : 1; //Correct for tightly packed spaces, and competing speech. //if (Area / (Men + Women + Kids) < 3.0f) //{ // //In overcrowded scenarios, vocal effort escalates as such: // //whispering becomes conversation. // //conversation becomes competing conversation. // //competing conversation becomes shouting. // //Singing stays singing... I'm pretty sure experienced singers wouldn't start shouting... // if (effort < 2) effort++; // else effort = 4; //} for (int oct = 0; oct < 8; oct++) { double Power = Men * Math.Pow(10, Males[effort][oct] / 10) + Women * Math.Pow(10, Females[effort][oct] / 10) + Kids * Math.Pow(10, Children[effort][oct] / 10); //Power /= (Area); SPL[oct] = 10 * Math.Log10(Power) + 11; } } else { Rhino.Input.RhinoGet.GetNumber("62.5 Hz. Sound Power Level", true, ref SPL[0]); Rhino.Input.RhinoGet.GetNumber("125 Hz. Sound Power Level", true, ref SPL[1]); Rhino.Input.RhinoGet.GetNumber("250 Hz. Sound Power Level", true, ref SPL[2]); Rhino.Input.RhinoGet.GetNumber("500 Hz. Sound Power Level", true, ref SPL[3]); Rhino.Input.RhinoGet.GetNumber("1000 Hz. Sound Power Level", true, ref SPL[4]); Rhino.Input.RhinoGet.GetNumber("2000 Hz. Sound Power Level", true, ref SPL[5]); Rhino.Input.RhinoGet.GetNumber("4000 Hz. Sound Power Level", true, ref SPL[6]); Rhino.Input.RhinoGet.GetNumber("8000 Hz. Sound Power Level", true, ref SPL[7]); } rhObj.Geometry.SetUserString("SWL", Utilities.PachTools.EncodeSourcePower(SPL)); rhObj.Geometry.SetUserString("Phase", "0;0;0;0;0;0;0;0"); doc.Objects.ModifyAttributes(rhObj, rhObj.Attributes, true); m_source_conduit.SetSource(rhObj); } doc.Views.Redraw(); return Result.Success; } else return Result.Cancel; } while (true); }
/// <summary>Easy to use bool getter.</summary> /// <param name="prompt">Command prompt.</param> /// <param name="acceptNothing">If true, the user can press enter.</param> /// <param name="offPrompt">The 'false/off' message.</param> /// <param name="onPrompt">The 'true/on' message.</param> /// <param name="boolValue">Default bool value set to this and returned here.</param> /// <returns>The getter result based on user choice. /// <para>Commands.Result.Success - got value.</para> /// <para>Commands.Result.Nothing - user pressed enter.</para> /// <para>Commands.Result.Cancel - user cancelled value getting.</para> /// </returns> public static Commands.Result GetBool(string prompt, bool acceptNothing, string offPrompt, string onPrompt, ref bool boolValue) { Commands.Result result = Commands.Result.Failure; using (Rhino.Input.Custom.GetOption get = new Rhino.Input.Custom.GetOption()) { get.SetCommandPrompt(prompt); get.AcceptNothing(acceptNothing); if (acceptNothing) get.SetDefaultString(boolValue ? onPrompt : offPrompt); int onValue = get.AddOption(onPrompt); int offValue = get.AddOption(offPrompt); get.Get(); result = get.CommandResult(); if (result == Commands.Result.Success && get.Result() == GetResult.Option) { Rhino.Input.Custom.CommandLineOption option = get.Option(); if (null != option) { if (option.Index == onValue) boolValue = true; else if (option.Index == offValue) boolValue = false; } } } return result; }