Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var panel_id = Views.UserStringsPanelControl.PanelId;
            var visible  = Panels.IsPanelVisible(panel_id);

            if (mode == RunMode.Scripted)
            {
                var go = new Rhino.Input.Custom.GetOption();
                go.SetCommandPrompt(LOC.STR("Choose document text option"));
                var hide_index   = go.AddOption("Hide");
                var show_index   = go.AddOption("Show");
                var toggle_index = go.AddOption("Toggle");
                go.Get();
                if (go.CommandResult() != Result.Success)
                {
                    return(go.CommandResult());
                }

                var option = go.Option();
                if (null == option)
                {
                    return(Result.Failure);
                }

                var index = option.Index;
                if (index == hide_index)
                {
                    if (visible)
                    {
                        Panels.ClosePanel(panel_id);
                    }
                }
                else if (index == show_index)
                {
                    if (!visible)
                    {
                        Panels.OpenPanel(panel_id);
                    }
                }
                else if (index == toggle_index)
                {
                    if (visible)
                    {
                        Panels.ClosePanel(panel_id);
                    }
                    else
                    {
                        Panels.OpenPanel(panel_id);
                    }
                }
            }
            else
            {
                Panels.OpenPanel(panel_id);
            }



            return(Result.Success);
        }
Esempio n. 4
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.UI.OpenFileDialog dialog = new Rhino.UI.OpenFileDialog();
            dialog.Title = "Open pointcloud file";
            dialog.ShowOpenDialog();

            Rhino.Input.Custom.OptionInteger optStep = new Rhino.Input.Custom.OptionInteger(4, 1, 1000);
            Rhino.Input.Custom.GetOption     getOpt  = new Rhino.Input.Custom.GetOption();
            getOpt.AddOptionInteger("Resolution", ref optStep);
            getOpt.SetCommandPrompt("Loading options");

            string path = dialog.FileName;

            if (!System.IO.File.Exists(path))
            {
                Rhino.RhinoApp.WriteLine("Farhino: Failed to find file...");
                return(Result.Failure);
            }

            getOpt.Get();

            Rhino.RhinoApp.WriteLine("Farhino: Step value: " + optStep.CurrentValue.ToString());
            RFContext.LoadScan(path, optStep.CurrentValue);

            return(Result.Success);
        }
Esempio n. 5
0
        protected override Rhino.Commands.Result RunCommand(Rhino.RhinoDoc doc, Rhino.Commands.RunMode mode)
        {
            System.Guid panelId  = SampleCsPanelUserControl.PanelId;
            bool        bVisible = Rhino.UI.Panels.IsPanelVisible(panelId);

            string prompt = (bVisible)
        ? "Sample panel is visible. New value"
        : "Sample Manager panel is hidden. New value";

            Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
            int hide_index   = go.AddOption("Hide");
            int show_index   = go.AddOption("Show");
            int toggle_index = go.AddOption("Toggle");

            go.Get();
            if (go.CommandResult() != Rhino.Commands.Result.Success)
            {
                return(go.CommandResult());
            }

            Rhino.Input.Custom.CommandLineOption option = go.Option();
            if (null == option)
            {
                return(Rhino.Commands.Result.Failure);
            }

            int index = option.Index;

            if (index == hide_index)
            {
                if (bVisible)
                {
                    Rhino.UI.Panels.ClosePanel(panelId);
                }
            }
            else if (index == show_index)
            {
                if (!bVisible)
                {
                    Rhino.UI.Panels.OpenPanel(panelId);
                }
            }
            else if (index == toggle_index)
            {
                if (bVisible)
                {
                    Rhino.UI.Panels.ClosePanel(panelId);
                }
                else
                {
                    Rhino.UI.Panels.OpenPanel(panelId);
                }
            }

            return(Rhino.Commands.Result.Success);
        }
Esempio n. 6
0
    public static Rhino.Commands.Result SpriteDrawing(RhinoDoc doc)
    {
        var sprite_mode  = new Rhino.Input.Custom.OptionToggle(m_draw_single_sprite, "SpriteList", "SingleSprite");
        var size_option  = new Rhino.Input.Custom.OptionDouble(m_sprite_size);
        var space_option = new Rhino.Input.Custom.OptionToggle(m_draw_world_location, "Screen", "World");
        var go           = new Rhino.Input.Custom.GetOption();

        go.SetCommandPrompt("Sprite drawing mode");
        go.AddOptionToggle("Mode", ref sprite_mode);
        go.AddOptionDouble("Size", ref size_option);
        go.AddOptionToggle("DrawSpace", ref space_option);
        int option_go   = go.AddOption("Spin");
        int option_file = go.AddOption("FileSprite");

        Rhino.Display.DisplayPipeline.PostDrawObjects      += DisplayPipeline_PostDrawObjects;
        Rhino.Display.DisplayPipeline.CalculateBoundingBox += DisplayPipeline_CalculateBoundingBox;

        doc.Views.Redraw();
        while (go.Get() == Rhino.Input.GetResult.Option)
        {
            m_draw_single_sprite  = sprite_mode.CurrentValue;
            m_sprite_size         = (float)size_option.CurrentValue;
            m_draw_world_location = space_option.CurrentValue;
            if (go.OptionIndex() == option_go)
            {
                var gs = new Rhino.Input.Custom.GetOption();
                gs.SetCommandPrompt("press enter/escape to end");
                gs.SetWaitDuration(1);

                var vp = doc.Views.ActiveView.MainViewport;
                while (gs.Get() == Rhino.Input.GetResult.Timeout)
                {
                    vp.Rotate(0.1, Vector3d.ZAxis, Point3d.Origin);
                    doc.Views.Redraw();
                }
            }
            else if (go.OptionIndex() == option_file)
            {
                var dlg = new Rhino.UI.OpenFileDialog();
                if (dlg.ShowDialog())
                {
                    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(dlg.FileName);
                    m_sprite = new Rhino.Display.DisplayBitmap(bmp);
                }
                doc.Views.Redraw();
            }
            else
            {
                doc.Views.Redraw();
            }
        }

        Rhino.Display.DisplayPipeline.PostDrawObjects      -= DisplayPipeline_PostDrawObjects;
        Rhino.Display.DisplayPipeline.CalculateBoundingBox -= DisplayPipeline_CalculateBoundingBox;
        return(Rhino.Commands.Result.Success);
    }
    protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
    {
      var sprite_mode = new Rhino.Input.Custom.OptionToggle(m_draw_single_sprite, "SpriteList", "SingleSprite");
      var size_option = new Rhino.Input.Custom.OptionDouble(m_sprite_size);
      var space_option = new Rhino.Input.Custom.OptionToggle(m_draw_world_location, "Screen", "World");
      var go = new Rhino.Input.Custom.GetOption();
      go.SetCommandPrompt("Sprite drawing mode");
      go.AddOptionToggle("Mode", ref sprite_mode);
      go.AddOptionDouble("Size", ref size_option);
      go.AddOptionToggle("DrawSpace", ref space_option);
      int option_go = go.AddOption("Spin");
      int option_file = go.AddOption("FileSprite");

      Rhino.Display.DisplayPipeline.PostDrawObjects += DisplayPipeline_PostDrawObjects;
      Rhino.Display.DisplayPipeline.CalculateBoundingBox += DisplayPipeline_CalculateBoundingBox;

      doc.Views.Redraw();
      while (go.Get() == Rhino.Input.GetResult.Option)
      {
        m_draw_single_sprite = sprite_mode.CurrentValue;
        m_sprite_size = (float)size_option.CurrentValue;
        m_draw_world_location = space_option.CurrentValue;
        if (go.OptionIndex() == option_go)
        {
          var gs = new Rhino.Input.Custom.GetOption();
          gs.SetCommandPrompt("press enter/escape to end");
          gs.SetWaitDuration(1);

          var vp = doc.Views.ActiveView.MainViewport;
          while (gs.Get() == Rhino.Input.GetResult.Timeout)
          {
            vp.Rotate(0.1, Vector3d.ZAxis, Point3d.Origin);
            doc.Views.Redraw();
          }
        }
        else if (go.OptionIndex() == option_file)
        {
          System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
          if (dlg.ShowDialog(RhinoApp.MainWindow()) == System.Windows.Forms.DialogResult.OK)
          {
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(dlg.FileName);
            m_sprite = new Rhino.Display.DisplayBitmap(bmp);
          }
          doc.Views.Redraw();
        }
        else
          doc.Views.Redraw();
      }

      Rhino.Display.DisplayPipeline.PostDrawObjects -= DisplayPipeline_PostDrawObjects;
      Rhino.Display.DisplayPipeline.CalculateBoundingBox -= DisplayPipeline_CalculateBoundingBox;
      return Rhino.Commands.Result.Success;
    }
        private bool SetPageUnit(RhinoDoc doc)
        {
            bool result = false;

            try
            {
                Rhino.Input.Custom.GetOption getOption = new Rhino.Input.Custom.GetOption();
                getOption.SetCommandPrompt("Set Page Units");

                foreach (string unit in optionValues)
                {
                    getOption.AddOption(unit);
                }

                getOption.Get();
                if (getOption.CommandResult() != Rhino.Commands.Result.Success)
                {
                    return(false);
                }

                string selectedUnit = getOption.Option().EnglishName;
                switch (selectedUnit)
                {
                case "Inch":
                    doc.AdjustPageUnitSystem(UnitSystem.Inches, true);
                    break;

                case "Foot":
                    doc.AdjustPageUnitSystem(UnitSystem.Feet, true);
                    break;

                case "Millimeter":
                    doc.AdjustPageUnitSystem(UnitSystem.Millimeters, true);
                    break;

                case "Centimeter":
                    doc.AdjustPageUnitSystem(UnitSystem.Centimeters, true);
                    break;

                case "Meter":
                    doc.AdjustPageUnitSystem(UnitSystem.Meters, true);
                    break;
                }

                doc.Views.Redraw();
                result = true;
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(result);
        }
Esempio n. 9
0
    public static Rhino.Commands.Result ObjectDisplayMode(Rhino.RhinoDoc doc)
    {
        const ObjectType filter = ObjectType.Mesh | ObjectType.Brep;
        ObjRef           objref;
        Result           rc = Rhino.Input.RhinoGet.GetOneObject("Select mesh or surface", true, filter, out objref);

        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }
        Guid viewportId = doc.Views.ActiveView.ActiveViewportID;

        ObjectAttributes attr = objref.Object().Attributes;

        if (attr.HasDisplayModeOverride(viewportId))
        {
            RhinoApp.WriteLine("Removing display mode override from object");
            attr.RemoveDisplayModeOverride(viewportId);
        }
        else
        {
            Rhino.Display.DisplayModeDescription[] modes = Rhino.Display.DisplayModeDescription.GetDisplayModes();
            Rhino.Display.DisplayModeDescription   mode  = null;
            if (modes.Length == 1)
            {
                mode = modes[0];
            }
            else
            {
                Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
                go.SetCommandPrompt("Select display mode");
                string[] str_modes = new string[modes.Length];
                for (int i = 0; i < modes.Length; i++)
                {
                    str_modes[i] = modes[i].EnglishName.Replace(" ", "").Replace("-", "");
                }
                go.AddOptionList("DisplayMode", str_modes, 0);
                if (go.Get() == Rhino.Input.GetResult.Option)
                {
                    mode = modes[go.Option().CurrentListOptionIndex];
                }
            }
            if (mode == null)
            {
                return(Rhino.Commands.Result.Cancel);
            }
            attr.SetDisplayModeOverride(mode, viewportId);
        }
        doc.Objects.ModifyAttributes(objref, attr, false);
        doc.Views.Redraw();
        return(Rhino.Commands.Result.Success);
    }
        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 Rhino.Commands.Result RunCommand(Rhino.RhinoDoc doc, Rhino.Commands.RunMode mode)
        {
            System.Guid panelId = SampleCsPanelUserControl.PanelId;
              bool bVisible = Rhino.UI.Panels.IsPanelVisible(panelId);

              string prompt = (bVisible)
            ? "Sample panel is visible. New value"
            : "Sample Manager panel is hidden. New value";

              Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
              int hide_index = go.AddOption("Hide");
              int show_index = go.AddOption("Show");
              int toggle_index = go.AddOption("Toggle");

              go.Get();
              if (go.CommandResult() != Rhino.Commands.Result.Success)
            return go.CommandResult();

              Rhino.Input.Custom.CommandLineOption option = go.Option();
              if (null == option)
            return Rhino.Commands.Result.Failure;

              int index = option.Index;

              if (index == hide_index)
              {
            if (bVisible)
              Rhino.UI.Panels.ClosePanel(panelId);
              }
              else if (index == show_index)
              {
            if (!bVisible)
              Rhino.UI.Panels.OpenPanel(panelId);
              }
              else if (index == toggle_index)
              {
            if (bVisible)
              Rhino.UI.Panels.ClosePanel(panelId);
            else
              Rhino.UI.Panels.OpenPanel(panelId);
              }

              return Rhino.Commands.Result.Success;
        }
        protected override Rhino.Commands.Result RunCommand(Rhino.RhinoDoc doc, Rhino.Commands.RunMode mode)
        {
            var panel_id = Views.SampleCsEtoPanel.PanelId;
              var visible = Rhino.UI.Panels.IsPanelVisible(panel_id);

              var prompt = (visible)
            ? "Sample panel is visible. New value"
            : "Sample panel is hidden. New value";

              var go = new Rhino.Input.Custom.GetOption();
              go.SetCommandPrompt(prompt);
              var hide_index = go.AddOption("Hide");
              var show_index = go.AddOption("Show");
              var toggle_index = go.AddOption("Toggle");
              go.Get();
              if (go.CommandResult() != Rhino.Commands.Result.Success)
            return go.CommandResult();

              var option = go.Option();
              if (null == option)
            return Rhino.Commands.Result.Failure;

              var index = option.Index;
              if (index == hide_index)
              {
            if (visible)
              Rhino.UI.Panels.ClosePanel(panel_id);
              }
              else if (index == show_index)
              {
            if (!visible)
              Rhino.UI.Panels.OpenPanel(panel_id);
              }
              else if (index == toggle_index)
              {
            if (visible)
              Rhino.UI.Panels.ClosePanel(panel_id);
            else
              Rhino.UI.Panels.OpenPanel(panel_id);
              }

              return Rhino.Commands.Result.Success;
        }
Esempio n. 13
0
        private void GetNestingSettings()
        {
            //Parameters
            Rhino.Input.Custom.GetOption gp = new Rhino.Input.Custom.GetOption();
            gp.SetCommandPrompt("OpenNest: Set nesting settings");

            Rhino.Input.Custom.OptionInteger Iterations     = new Rhino.Input.Custom.OptionInteger(1, 1, 100);
            Rhino.Input.Custom.OptionDouble  Spacing        = new Rhino.Input.Custom.OptionDouble(0.01, 0.001, 10);
            Rhino.Input.Custom.OptionInteger Placement      = new Rhino.Input.Custom.OptionInteger(1, 0, 4);
            Rhino.Input.Custom.OptionDouble  Tolerance      = new Rhino.Input.Custom.OptionDouble(0.1, 0.01, 10);
            Rhino.Input.Custom.OptionInteger Rotations      = new Rhino.Input.Custom.OptionInteger(4, 0, 360);
            Rhino.Input.Custom.OptionInteger Seed           = new Rhino.Input.Custom.OptionInteger(0, 1, 100);
            Rhino.Input.Custom.OptionDouble  ClosestObjects = new Rhino.Input.Custom.OptionDouble(0.01, 0, 100);

            gp.AddOptionInteger("Iterations", ref Iterations);
            gp.AddOptionDouble("Spacing", ref Spacing);
            gp.AddOptionInteger("Placement", ref Placement);
            gp.AddOptionDouble("Tolerance", ref Tolerance);
            gp.AddOptionInteger("Rotations", ref Rotations);
            gp.AddOptionInteger("Seed", ref Seed);
            gp.AddOptionDouble("ClosestObjects", ref ClosestObjects);

            while (true)
            {
                Rhino.Input.GetResult get_rc = gp.Get();
                if (gp.CommandResult() != Rhino.Commands.Result.Success)
                {
                    break;
                }
            }

            this.iterations    = Iterations.CurrentValue;
            this.spacing       = Spacing.CurrentValue;
            this.placementType = Placement.CurrentValue;
            this.tolerance     = Tolerance.CurrentValue;
            this.rotations     = Rotations.CurrentValue;
            this.seed          = Seed.CurrentValue;
            this.spacing      *= (1 / tolerance);
            this.cp            = ClosestObjects.CurrentValue;
        }
Esempio n. 14
0
        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);
            }
        }
Esempio n. 15
0
        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);
        }
    // The following example code demonstrates how to modify advanced display settings using
    // the Rhino SDK. In this example, a display mode's mesh wireframe thickness (in pixels)
    // will be modified.
    public static Rhino.Commands.Result AdvancedDisplay(Rhino.RhinoDoc doc)
    {
        // Use the display attributes manager to build a list of display modes.
        // Note, these are copies of the originals...
        DisplayModeDescription[] display_modes = DisplayModeDescription.GetDisplayModes();
        if (display_modes == null || display_modes.Length < 1)
        {
            return(Rhino.Commands.Result.Failure);
        }

        // Construct an options picker so the user can pick which
        // display mode they want modified
        Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
        go.SetCommandPrompt("Display mode to modify mesh thickness");
        List <int> opt_list = new List <int>();

        for (int i = 0; i < display_modes.Length; i++)
        {
            string english_name = display_modes[i].EnglishName;
            english_name = english_name.Replace("_", "");
            english_name = english_name.Replace(" ", "");
            english_name = english_name.Replace("-", "");
            english_name = english_name.Replace(",", "");
            english_name = english_name.Replace(".", "");
            int index = go.AddOption(english_name);
            opt_list.Add(index);
        }

        // Get the command option
        go.Get();
        if (go.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(go.CommandResult());
        }

        int selected_index = go.Option().Index;
        DisplayModeDescription selected_description = null;

        for (int i = 0; i < opt_list.Count; i++)
        {
            if (opt_list[i] == selected_index)
            {
                selected_description = display_modes[i];
                break;
            }
        }

        // Validate...
        if (selected_description == null)
        {
            return(Rhino.Commands.Result.Failure);
        }

        // Modify the desired display mode. In this case, we
        // will just set the mesh wireframe thickness to zero.
        selected_description.DisplayAttributes.MeshSpecificAttributes.MeshWireThickness = 0;
        // Use the display attributes manager to update the display mode.
        DisplayModeDescription.UpdateDisplayMode(selected_description);

        // Force the document to regenerate.
        doc.Views.Redraw();
        return(Rhino.Commands.Result.Success);
    }
Esempio n. 17
0
 /// <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;
 }
            ///<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);
            }