/// <summary>
        /// Called by Rhino to 'run' this command
        /// </summary>
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Select objects to orient
            var go = new GetObject();

            go.SetCommandPrompt("Select objects to orient");
            go.SubObjectSelect = false;
            go.EnableIgnoreGrips(true);
            go.GetMultiple(1, 0);
            if (go.CommandResult() != Result.Success)
            {
                return(go.CommandResult());
            }

            // Point to move from
            var gp = new GetPoint();

            gp.SetCommandPrompt("Point to move from");
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            // Calculate source plane
            var plane = gp.View().ActiveViewport.ConstructionPlane();

            plane.Origin = gp.Point();

            // Mesh to orient on
            var gm = new GetObject();

            gm.SetCommandPrompt("Mesh to orient on");
            gm.GeometryFilter = ObjectType.Mesh;
            gm.EnablePreSelect(false, true);
            gm.DeselectAllBeforePostSelect = false;
            gm.Get();
            if (gm.CommandResult() != Result.Success)
            {
                return(gm.CommandResult());
            }

            var mesh = gm.Object(0).Mesh();

            if (null == mesh)
            {
                return(Result.Failure);
            }

            // Point on mesh to orient to
            var gpm = new GetPointOnMesh(mesh, plane);

            gpm.SetCommandPrompt("Point on mesh to orient to");
            gpm.AppendObjects(go);
            gpm.Get();
            if (gpm.CommandResult() != Result.Success)
            {
                return(gpm.CommandResult());
            }

            // One final calculation
            var xform = new Transform(1);

            if (gpm.CalculateTransform(gpm.View().ActiveViewport, gpm.Point(), ref xform))
            {
                foreach (var objRef in go.Objects())
                {
                    var obj = objRef.Object();
                    if (null != obj)
                    {
                        doc.Objects.Transform(obj, xform, true);
                    }
                }
                doc.Views.Redraw();
            }

            return(Result.Success);
        }