SampleCsSurfaceDirectionConduit
Inheritance: MRhinoDisplayConduit
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MRhinoGetObject go = new MRhinoGetObject();
              go.SetCommandPrompt("Select surface or polysurface for direction display");
              go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object | IRhinoGetObject.GEOMETRY_TYPE_FILTER.polysrf_object);
              go.GetObjects(1, 1);
              if (go.CommandResult() != IRhinoCommand.result.success)
            return go.CommandResult();

              MRhinoObjRef obj_ref = go.Object(0);
              IOnBrep brep = obj_ref.Brep();
              if (null == brep)
            return IRhinoCommand.result.failure;

              bool bIsSolid = brep.IsSolid();
              bool bFlip = false;

              SampleCsSurfaceDirectionConduit conduit = new SampleCsSurfaceDirectionConduit();
              conduit.SetBrep(brep);
              conduit.Enable();
              context.m_doc.Redraw();

              MRhinoGetOption gf = new MRhinoGetOption();
              gf.SetCommandPrompt("Press Enter when done");
              gf.AcceptNothing();
              if (!bIsSolid)
            gf.AddCommandOption(new MRhinoCommandOptionName("Flip"));

              for (; ; )
              {
            IRhinoGet.result res = gf.GetOption();

            if (res == IRhinoGet.result.option)
            {
              bFlip = !bFlip;
              conduit.SetFlip(bFlip);
              context.m_doc.Redraw();
              continue;
            }

            if (res == IRhinoGet.result.nothing)
            {
              if (!bIsSolid && bFlip)
              {
            OnBrep flipped_brep = new OnBrep(brep);
            flipped_brep.Flip();
            context.m_doc.ReplaceObject(obj_ref, flipped_brep);
              }
            }

            break;
              }

              conduit.Disable();
              context.m_doc.Redraw();

              return IRhinoCommand.result.success;
        }
Example #2
0
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MRhinoGetObject go = new MRhinoGetObject();

            go.SetCommandPrompt("Select surface or polysurface for direction display");
            go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object | IRhinoGetObject.GEOMETRY_TYPE_FILTER.polysrf_object);
            go.GetObjects(1, 1);
            if (go.CommandResult() != IRhinoCommand.result.success)
            {
                return(go.CommandResult());
            }

            MRhinoObjRef obj_ref = go.Object(0);
            IOnBrep      brep    = obj_ref.Brep();

            if (null == brep)
            {
                return(IRhinoCommand.result.failure);
            }

            bool bIsSolid = brep.IsSolid();
            bool bFlip    = false;

            SampleCsSurfaceDirectionConduit conduit = new SampleCsSurfaceDirectionConduit();

            conduit.SetBrep(brep);
            conduit.Enable();
            context.m_doc.Redraw();

            MRhinoGetOption gf = new MRhinoGetOption();

            gf.SetCommandPrompt("Press Enter when done");
            gf.AcceptNothing();
            if (!bIsSolid)
            {
                gf.AddCommandOption(new MRhinoCommandOptionName("Flip"));
            }

            for (; ;)
            {
                IRhinoGet.result res = gf.GetOption();

                if (res == IRhinoGet.result.option)
                {
                    bFlip = !bFlip;
                    conduit.SetFlip(bFlip);
                    context.m_doc.Redraw();
                    continue;
                }

                if (res == IRhinoGet.result.nothing)
                {
                    if (!bIsSolid && bFlip)
                    {
                        OnBrep flipped_brep = new OnBrep(brep);
                        flipped_brep.Flip();
                        context.m_doc.ReplaceObject(obj_ref, flipped_brep);
                    }
                }

                break;
            }

            conduit.Disable();
            context.m_doc.Redraw();

            return(IRhinoCommand.result.success);
        }