public static Result ModifyLightColor(RhinoDoc doc)
    {
        ObjRef obj_ref;
        var    rc = RhinoGet.GetOneObject("Select light to change color", true,
                                          ObjectType.Light, out obj_ref);

        if (rc != Result.Success)
        {
            return(rc);
        }
        var light = obj_ref.Light();

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

        var diffuse_color = light.Diffuse;

        if (Dialogs.ShowColorDialog(ref diffuse_color))
        {
            light.Diffuse = diffuse_color;
        }

        doc.Lights.Modify(obj_ref.ObjectId, light);
        return(Result.Success);
    }
Exemple #2
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            ObjRef sRef;
            Result r = RhinoGet.GetOneObject("Pick closed curve", false, ObjectType.Curve, out sRef);

            if (r != Result.Success || null == sRef)
            {
                return(r);
            }

            RhinoObject obj = sRef.Object();

            obj.Attributes.SetUserString("Name", "Concrete");
            Curve selectedCurve = sRef.Curve();


            //if the curve is not closed do nothing
            if (!selectedCurve.IsClosed)
            {
                Rhino.RhinoApp.WriteLine("The curve was not closed!!");
                return(Result.Success);
            }

            List <Brep>  breps        = new List <Brep>();
            List <Curve> cuttedCurves = CurveAndBrepManipulation.cutCurve(selectedCurve, Plane.WorldXY, Axis.XAxis);

            foreach (Curve curve in cuttedCurves)
            {
                breps.AddRange(Brep.CreatePlanarBreps(curve));
            }


            DrawAndSaveUserAttr(breps, doc, obj);
            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            const ObjectType filter = ObjectType.AnyObject;
            ObjRef           objref;
            var rc = RhinoGet.GetOneObject("Select object", false, filter, out objref);

            if (rc != Result.Success || null == objref)
            {
                return(rc);
            }

            var obj = objref.Object();

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

            var ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject;

            if (null != ud)
            {
                var gs = new GetString();
                gs.SetCommandPrompt("Modify object notes");
                gs.GetLiteralString();
                if (gs.CommandResult() != Result.Success)
                {
                    return(gs.CommandResult());
                }

                ud.Notes = gs.StringResult();
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            ObjRef object_ref;
            var    rc = RhinoGet.GetOneObject("Select curve for stacked control point test", false, ObjectType.Curve, out object_ref);

            if (rc != Result.Success)
            {
                return(rc);
            }

            var nc = object_ref.Curve() as NurbsCurve;

            if (null == nc)
            {
                RhinoApp.WriteLine("Curve is not a NURBS curve.");
                return(Result.Success);
            }

            var b = IsStackedControlPointsCurve(nc);

            if (b)
            {
                RhinoApp.WriteLine("NURBS curve has stacked control points.");
            }
            else
            {
                RhinoApp.WriteLine("NURBS curve does not have stacked control points.");
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var view = doc.Views.ActiveView;

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

            var conduit = new SampleCsDrawGrayscaleConduit(view.ActiveViewportID)
            {
                Enabled = true
            };

            doc.Views.Redraw();

            string out_str = null;

            RhinoGet.GetString("Press <Enter> to continue", true, ref out_str);

            conduit.Enabled = false;
            doc.Views.Redraw();

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            const ObjectType filter = ObjectType.AnyObject;
            ObjRef           objref;
            var rc = RhinoGet.GetOneObject("Select object", false, filter, out objref);

            if (rc != Result.Success || null == objref)
            {
                return(rc);
            }

            var obj = objref.Object();

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

            var ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject;

            if (null != ud)
            {
                obj.Attributes.UserData.Remove(ud);
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            RhinoView view = doc.Views.ActiveView;

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

            string name = null;
            Result rc   = RhinoGet.GetString("Named view to restore", false, ref name);

            if (rc != Result.Success || string.IsNullOrEmpty(name))
            {
                return(Result.Cancel);
            }

            int index = doc.NamedViews.FindByName(name);

            if (index < 0 || index >= doc.NamedViews.Count)
            {
                RhinoApp.WriteLine("Named view not found");
                return(Result.Nothing);
            }

            //doc.NamedViews.Restore(index, view, false);
            doc.NamedViews.RestoreAnimated(index, view, false);
            view.Redraw();

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Plane  plane  = Plane.WorldXY;
            double radius = 10.0;
            double height = 2.0;

            Circle   circle   = new Circle(plane, radius);
            Cylinder cylinder = new Cylinder(circle, height);

            Brep brep = Brep.CreateFromCylinder(cylinder, true, true);

            SampleCsShadedBrepConduit conduit = new SampleCsShadedBrepConduit();

            conduit.BrepGeometry = brep;
            conduit.Enabled      = true;
            doc.Views.Redraw();

            string out_str = null;

            RhinoGet.GetString("Press <Enter> to continue", true, ref out_str);

            conduit.Enabled = false;

            doc.Objects.AddBrep(brep);
            doc.Views.Redraw();

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            const ObjectType filter = ObjectType.AnyObject;
            ObjRef           objref;
            var rc = RhinoGet.GetOneObject("Select object", false, filter, out objref);

            if (rc != Result.Success || null == objref)
            {
                return(rc);
            }

            var obj = objref.Object();

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

            var userdata = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject;

            if (null != userdata)
            {
                RhinoApp.WriteLine("{0} = {1}", userdata.Description, userdata.Notes);
            }
            else
            {
                RhinoApp.WriteLine("SampleCsUserData not found.");
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            ObjRef obj_ref;
            var    rc = RhinoGet.GetOneObject(
                "Select edge curve", false, ObjectType.EdgeFilter, out obj_ref);

            if (rc != Result.Success)
            {
                return(rc);
            }
            var edge = obj_ref.Edge();

            var face_idxs        = edge.AdjacentFaces();
            var edge_owning_brep = edge.Brep;

            foreach (var idx in face_idxs)
            {
                var face      = edge_owning_brep.Faces[idx];
                var face_copy = face.DuplicateFace(true);
                var id        = doc.Objects.AddBrep(face_copy);
                doc.Objects.Find(id).Select(true);
            }
            doc.Views.Redraw();
            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var data_table = SampleCsUserDataPlugIn.Instance.SimpleDocumentDataTable;

            if (0 == data_table.Count)
            {
                var number = 6;
                var rc     = RhinoGet.GetInteger("Number of data objects to create", true, ref number, 1, 100);
                if (rc != Result.Success)
                {
                    return(rc);
                }

                for (var i = 0; i < number; i++)
                {
                    data_table.Add(new SampleCsSimpleDocumentData());
                }
            }

            for (var i = 0; i < data_table.Count; i++)
            {
                RhinoApp.WriteLine("Data[{0}] = {1}", i, data_table[i].Value);
            }

            return(Result.Success);
        }
Exemple #12
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            ObjRef obj_ref;
            var    rc = RhinoGet.GetOneObject("Select object", false, ObjectType.AnyObject, out obj_ref);

            if (rc != Result.Success)
            {
                return(rc);
            }
            var  rhino_object = obj_ref.Object();
            var  color        = rhino_object.Attributes.ObjectColor;
            bool b            = Rhino.UI.Dialogs.ShowColorDialog(ref color);

            if (!b)
            {
                return(Result.Cancel);
            }

            rhino_object.Attributes.ObjectColor = color;
            rhino_object.Attributes.ColorSource = ObjectColorSource.ColorFromObject;
            rhino_object.CommitChanges();

            // an object's color attributes can also be specified
            // when the object is added to Rhino
            var sphere     = new Sphere(Point3d.Origin, 5.0);
            var attributes = new ObjectAttributes();

            attributes.ObjectColor = Color.CadetBlue;
            attributes.ColorSource = ObjectColorSource.ColorFromObject;
            doc.Objects.AddSphere(sphere, attributes);

            doc.Views.Redraw();
            return(Result.Success);
        }
Exemple #13
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // get mesh
            var rc = RhinoGet.GetOneObject("Pick mesh", false, ObjectType.Mesh, out var objRef);

            if (rc != Result.Success)
            {
                return(rc);
            }

            var mesh = objRef.Mesh();

            doc.Views.RedrawEnabled = false;

            var pMesh = mesh.ToPlanktonMeshWithNgons();

            for (int i = pMesh.Faces.Count - 1; i >= 0; i--)
            {
                if (pMesh.Faces.GetFaceVertices(i).Length == 3)
                {
                    pMesh.Faces.RemoveFace(i);
                }
            }

            pMesh.Compact();

            mesh = pMesh.ToRhinoMeshWithNgons();
            doc.Objects.Replace(objRef, mesh);

            doc.Views.RedrawEnabled = true;
            doc.Views.Redraw();

            return(Result.Success);
        }
Exemple #14
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var rc = RhinoGet.GetOneObject("Select object", false, ObjectType.AnyObject, out var objref);

            if (rc != Result.Success)
            {
                return(rc);
            }

            var obj = objref.Object();

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

            if (!(obj.Attributes.UserData.Find(typeof(SampleCsCustomUserData)) is SampleCsCustomUserData ud))
            {
                var rand = new Random();
                ud = new SampleCsCustomUserData
                {
                    Data =
                    {
                        X = rand.NextDouble(),
                        Y = rand.NextDouble(),
                        Z = rand.NextDouble()
                    }
                };
                obj.Attributes.UserData.Add(ud);
            }

            RhinoApp.WriteLine("{0} = {1}", ud.Description, ud.Data);

            return(Result.Success);
        }
Exemple #15
0
        /// <summary>
        /// launch rhino get object command
        /// </summary>
        /// <param name="parent">parent form that started the command</param>
        /// <param name="ot">selection object type</param>
        /// <returns>array of ObjRef</returns>
        private ObjRef[] PickObj(ObjectType ot = ObjectType.AnyObject)
        {
            WindowState = FormWindowState.Minimized;

            //ObjRef[] picked = await Task.Run(() =>
            //{
            //    Result r = RhinoGet.GetMultipleObjects(" select object(s)", true, ot, out ObjRef[] objs);
            //    if (r == Result.Success)
            //        return objs;
            //    else return new ObjRef[] { };
            //});
            //parent.TopMost = true;
            //parent.BringToFront();
            //return picked;


            Result r = RhinoGet.GetMultipleObjects(" select object(s)", true, ot, out ObjRef[] picked);

            if (r == Result.Success)
            {
                WindowState = FormWindowState.Normal;
                return(picked);
            }
            else
            {
                RhinoApp.WriteLine(" nothing selected...");
                WindowState = FormWindowState.Normal;
                return(new ObjRef[] { });
            }
        }
    public static Result IsPlanarSurfaceInPlane(RhinoDoc doc)
    {
        ObjRef obj_ref;
        var    rc = RhinoGet.GetOneObject("select surface", true, ObjectType.Surface, out obj_ref);

        if (rc != Result.Success)
        {
            return(rc);
        }
        var surface = obj_ref.Surface();

        Point3d[] corners;
        rc = RhinoGet.GetRectangle(out corners);
        if (rc != Result.Success)
        {
            return(rc);
        }

        var plane = new Plane(corners[0], corners[1], corners[2]);

        var is_or_isnt = " not ";

        if (IsSurfaceInPlane(surface, plane, doc.ModelAbsoluteTolerance))
        {
            is_or_isnt = "";
        }

        RhinoApp.WriteLine("Surface is{0} in plane.", is_or_isnt);
        return(Result.Success);
    }
Exemple #17
0
        /// <summary>.
        /// Enable mobile plane's dynamic construction plane update.
        /// </summary>
        private Result EnableOption(RhinoDoc doc, RhinoObject obj)
        {
            if (null == doc || null == obj)
            {
                return(Result.Failure);
            }

            if (!SampleCsMobilePlaneUserData.IsAttached(obj))
            {
                RhinoApp.WriteLine("No mobile plane attached.");
                return(Result.Success);
            }

            var enable = SampleCsMobilePlaneUserData.IsEnabled(obj);
            var res    = RhinoGet.GetBool("Enable object mobile plane", true, "Disable", "Enable", ref enable);

            if (res != Result.Success)
            {
                return(res);
            }

            var rc = SampleCsMobilePlaneUserData.Enable(obj, enable);

            return(rc ? Result.Success : Result.Failure);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.DocObjects.ObjRef objref;
            var rc = RhinoGet.GetOneObject("Select Curve", false, ObjectType.Curve, out objref);

            if (rc != Result.Success)
            {
                return(rc);
            }
            var curve = objref.Curve();

            var view  = doc.Views.ActiveView;
            var plane = view.ActiveViewport.ConstructionPlane();
            // Create a construction plane aligned bounding box
            var bbox = curve.GetBoundingBox(plane);

            if (bbox.IsDegenerate(doc.ModelAbsoluteTolerance) > 0)
            {
                RhinoApp.WriteLine("the curve's bounding box is degenerate (flat) in at least one direction so a box cannot be created.");
                return(Result.Failure);
            }
            var brep = Brep.CreateFromBox(bbox);

            doc.Objects.AddBrep(brep);
            doc.Views.Redraw();
            return(Result.Success);
        }
        /// <summary>
        /// Called by Rhino when the user wants to run the command.
        /// </summary>
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            GetOption go = new GetOption();

            go.SetCommandPrompt("Select command option");
            int add_index    = go.AddOption("Add");
            int delete_index = go.AddOption("Delete");
            int list_index   = go.AddOption("List");

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

            CommandLineOption option = go.Option();

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

            int index = option.Index;

            if (index == add_index)
            {
                string str = string.Empty;
                Result rc  = RhinoGet.GetString("String to add", false, ref str);
                if (rc == Result.Success)
                {
                    SampleCsStringTableHelpers.Add(str);
                }
            }
            else if (index == delete_index)
            {
                string str = string.Empty;
                Result rc  = RhinoGet.GetString("String to delete", false, ref str);
                if (rc == Result.Success)
                {
                    SampleCsStringTableHelpers.Remove(str);
                }
            }
            else if (index == list_index)
            {
                int count = SampleCsStringTableHelpers.Count();
                if (0 == count)
                {
                    RhinoApp.WriteLine("0 string items to list.");
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        RhinoApp.WriteLine(SampleCsStringTableHelpers.GetAt(i));
                    }
                }
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var gf = RhinoGet.GetFileName(GetFileNameMode.OpenImage, "*.3dm", "select file", null);

            if (gf == string.Empty || !System.IO.File.Exists(gf))
            {
                return(Result.Cancel);
            }

            var bitmap = Rhino.FileIO.File3dm.ReadPreviewImage(gf);
            // convert System.Drawing.Bitmap to BitmapSource
            var image_source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero,
                                                                                            Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());

            // show in WPF window
            var window = new Window();
            var image  = new Image {
                Source = image_source
            };

            window.Content = image;
            window.Show();

            return(Result.Success);
        }
    public static Result GetAngle(RhinoDoc doc)
    {
        var gp = new GetPoint();

        gp.SetCommandPrompt("Base point");
        gp.Get();
        if (gp.CommandResult() != Result.Success)
        {
            return(gp.CommandResult());
        }
        var base_point = gp.Point();

        gp.SetCommandPrompt("First reference point");
        gp.DrawLineFromPoint(base_point, true);
        gp.Get();
        if (gp.CommandResult() != Result.Success)
        {
            return(gp.CommandResult());
        }
        var first_point = gp.Point();

        double angle_radians;
        var    rc = RhinoGet.GetAngle("Second reference point", base_point, first_point, 0, out angle_radians);

        if (rc == Result.Success)
        {
            RhinoApp.WriteLine("Angle = {0} degrees", RhinoMath.ToDegrees(angle_radians));
        }

        return(rc);
    }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Define i/o parameters
            var run = false;

            // Read inputs
            if (!DA.GetData(0, ref run))
            {
                return;
            }

            if (run == true)
            {
                ///internal params
                const ObjectType filter = ObjectType.Mesh;
                /// select all meshes in doc
                RhinoGet.GetMultipleObjects("", true, filter, out ObjRef[] objref);

                /// access their materials
                ///
                for (int i = 0; i < objref.Length; i++)
                {
                    var    rhino_object    = objref[i].Object();
                    string new_object_name = rhino_object.GetMaterial(true).ToString();

                    /// set their names
                    ///
                    Name = new_object_name;
                    rhino_object.CommitChanges();
                }
            }
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Point3d base_pt;
            var     rc = RhinoGet.GetPoint("Start of line", false, out base_pt);

            if (rc != Result.Success)
            {
                return(rc);
            }

            var gp = new GetPoint();

            gp.SetCommandPrompt("End of line");
            gp.SetBasePoint(base_pt, true);
            gp.DrawLineFromPoint(base_pt, true);
            gp.DynamicDraw += gp_DynamicDraw;
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            var end_pt = gp.Point();
            var vector = end_pt - base_pt;

            if (vector.Length > doc.ModelAbsoluteTolerance)
            {
                var line = new Line(base_pt, end_pt);
                doc.Objects.AddLine(line);
                doc.Views.Redraw();
            }

            return(Result.Success);
        }
    public static Result ProjectPointsToMeshesEx(RhinoDoc doc)
    {
        ObjRef obj_ref;
        var    rc = RhinoGet.GetOneObject("mesh", false, ObjectType.Mesh, out obj_ref);

        if (rc != Result.Success)
        {
            return(rc);
        }
        var mesh = obj_ref.Mesh();

        ObjRef[] obj_ref_pts;
        rc = RhinoGet.GetMultipleObjects("points", false, ObjectType.Point, out obj_ref_pts);
        if (rc != Result.Success)
        {
            return(rc);
        }
        var points = new List <Point3d>();

        foreach (var obj_ref_pt in obj_ref_pts)
        {
            var pt = obj_ref_pt.Point().Location;
            points.Add(pt);
        }

        int[] indices;
        var   prj_points = Intersection.ProjectPointsToMeshesEx(new[] { mesh }, points, new Vector3d(0, 1, 0), 0, out indices);

        foreach (var prj_pt in prj_points)
        {
            doc.Objects.AddPoint(prj_pt);
        }
        doc.Views.Redraw();
        return(Result.Success);
    }
Exemple #25
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var filename = string.Empty;

            if (mode == Rhino.Commands.RunMode.Interactive)
            {
                filename = RhinoGet.GetFileName(GetFileNameMode.OpenRhinoOnly, null, "Open", RhinoApp.MainWindowHandle());
            }
            else
            {
                RhinoGet.GetString("Name of Rhino file to open", false, ref filename);
            }

            filename = filename.Trim();
            if (string.IsNullOrEmpty(filename))
            {
                return(Result.Cancel);
            }

            if (!System.IO.File.Exists(filename))
            {
                RhinoApp.WriteLine("File not found.");
                return(Result.Failure);
            }

            // Make sure to surround filename string with double-quote characters
            // in case the path contains spaces.
            var script = string.Format("_-Open \"{0}\"", filename);

            RhinoApp.RunScript(script, false);

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            ObjRef obj_ref;
            var    rc = RhinoGet.GetOneObject("Select object to change name", true, ObjectType.AnyObject, out obj_ref);

            if (rc != Result.Success)
            {
                return(rc);
            }
            var rhino_object = obj_ref.Object();

            var new_object_name = "";

            rc = RhinoGet.GetString("New object name", true, ref new_object_name);
            if (rc != Result.Success)
            {
                return(rc);
            }
            if (string.IsNullOrWhiteSpace(new_object_name))
            {
                return(Result.Nothing);
            }

            if (rhino_object.Name != new_object_name)
            {
                rhino_object.Attributes.Name = new_object_name;
                rhino_object.CommitChanges();
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Point3d basePt;
            Result  rc = RhinoGet.GetPoint("Start of line", false, out basePt);

            if (rc != Result.Success)
            {
                return(rc);
            }

            GetPoint gp = new GetPoint();

            gp.SetCommandPrompt("End of line");
            gp.SetBasePoint(basePt, true);
            gp.DrawLineFromPoint(basePt, true);
            gp.DynamicDraw += new EventHandler <GetPointDrawEventArgs>(gp_DynamicDraw);
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            Point3d endPt = gp.Point();

            Rhino.Geometry.Vector3d vector = endPt - basePt;
            if (vector.Length > doc.ModelAbsoluteTolerance)
            {
                Line line = new Line(basePt, endPt);
                doc.Objects.AddLine(line);
                doc.Views.Redraw();
            }

            return(Result.Success);
        }
Exemple #28
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var result = RhinoGet.GetMultipleObjects("Select faces", false, Rhino.DocObjects.ObjectType.Surface, out var rhObjects);

            if (result != Result.Success)
            {
                return(result);
            }

            var dialog = new ExportSettingsDialog();

            if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return(Result.Cancel);
            }

            foreach (var rhObject in rhObjects)
            {
                var geometry = GetGeometry(rhObject.Geometry());

                if (geometry == null)
                {
                    continue;
                }

                dialog.SaveData(geometry);
            }

            return(Result.Success);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Pick a mesh
            ObjRef obj_ref;
            Result rc = RhinoGet.GetOneObject("Select mesh", false, ObjectType.Mesh, out obj_ref);

            if (rc != Result.Success)
            {
                return(rc);
            }

            Rhino.Geometry.Mesh mesh = obj_ref.Mesh();
            if (null == mesh)
            {
                return(Result.Failure);
            }

            // Pick a point that is contrained to the mesh
            GetPoint gp = new GetPoint();

            gp.SetCommandPrompt("Pick point on mesh");
            gp.Constrain(mesh, false);
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            Point3d point = gp.Point();

            doc.Objects.AddPoint(point);
            doc.Views.Redraw();

            return(Result.Success);
        }
Exemple #30
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // get the path
            string path = string.Empty;

            RhinoGet.GetString("Absolute path of the exexutable", true, ref path);
            if (string.IsNullOrEmpty(path))
            {
                RhinoApp.WriteLine("Cancelled.");
                return(Result.Cancel);
            }
            // valdiate path
            if (!File.Exists(path))
            {
                RhinoApp.WriteLine("File path is not valid.");
                return(Result.Cancel);
            }
            // run the file
            try
            {
                Process.Start(path);
            }
            catch (Exception e)
            {
                RhinoApp.WriteLine(e.Message);
            }

            return(Result.Success);
        }