예제 #1
0
        /// <summary>
        /// If Style==Wireframe, then the default decomposes the curve object into
        /// nurbs curve segments and calls the virtual DrawNurbsCurve for each segment.
        /// </summary>
        /// <param name="curve">A document curve object.</param>
        /// <param name="pipeline">The drawing pipeline.</param>
        protected virtual void DrawCurveObject(Rhino.DocObjects.CurveObject curve, DisplayPipeline pipeline)
        {
            IntPtr pConstThis  = ConstPointer();
            IntPtr pConstCurve = curve.ConstPointer();
            IntPtr pPipeline   = pipeline.NonConstPointer();

            UnsafeNativeMethods.CRhinoVisualAnalysisMode_DrawCurveObject(pConstThis, pConstCurve, pPipeline);
        }
예제 #2
0
        static void OnDrawRhinoObjectProc(Guid am_id, IntPtr pConstRhinoObject, IntPtr pRhinoDisplayPipeline)
        {
            VisualAnalysisMode mode = FindLocal(am_id);

            if (mode != null)
            {
                var             rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pConstRhinoObject);
                DisplayPipeline dp    = new DisplayPipeline(pRhinoDisplayPipeline);
                try
                {
                    Rhino.DocObjects.BrepObject brep = rhobj as Rhino.DocObjects.BrepObject;
                    if (brep != null)
                    {
                        mode.DrawBrepObject(brep, dp);
                        return;
                    }
                    Rhino.DocObjects.CurveObject curve = rhobj as Rhino.DocObjects.CurveObject;
                    if (curve != null)
                    {
                        mode.DrawCurveObject(curve, dp);
                        return;
                    }
                    Rhino.DocObjects.MeshObject mesh = rhobj as Rhino.DocObjects.MeshObject;
                    if (mesh != null)
                    {
                        mode.DrawMeshObject(mesh, dp);
                        return;
                    }
                    Rhino.DocObjects.PointCloudObject pointcloud = rhobj as Rhino.DocObjects.PointCloudObject;
                    if (pointcloud != null)
                    {
                        mode.DrawPointCloudObject(pointcloud, dp);
                        return;
                    }
                    Rhino.DocObjects.PointObject pointobj = rhobj as Rhino.DocObjects.PointObject;
                    if (pointobj != null)
                    {
                        mode.DrawPointObject(pointobj, dp);
                        return;
                    }
                }
                catch (Exception) { }
            }
        }
        /// <summary>
        /// 새로운 경계 입력 함수
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>



        private void Btn_GetPlot_Copy1_Click(object sender, RoutedEventArgs e)
        {
            Btn_GetPlot_Copy1.Click -= Btn_GetPlot_Copy1_Click;
            //var gcc = new GetObject();
            //gcc.SetCommandPrompt("select closed curve");
            //gcc.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
            //gcc.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve;
            //gcc.SubObjectSelect = false;
            //RhinoApp.RunScript("Polyline", true);
            //RhinoApp.RunScript("SelLast", true);



            ButtonStateCheck(ButtonState.None);
            Rhino.ApplicationSettings.ModelAidSettings.OsnapModes = Rhino.ApplicationSettings.OsnapModes.None;
            Rhino.ApplicationSettings.ModelAidSettings.OsnapModes = Rhino.ApplicationSettings.OsnapModes.End;


            var result = RhinoApp.RunScript("Polyline", true);

            Rhino.ApplicationSettings.ModelAidSettings.OsnapModes = Rhino.ApplicationSettings.OsnapModes.None;

            System.Guid guid = System.Guid.Empty;

            if (result)
            {
                guid = RhinoDoc.ActiveDoc.Objects.ElementAt(0).Id;
                var c = RhinoDoc.ActiveDoc.Objects.Find(guid);
                Rhino.DocObjects.CurveObject d = c as Rhino.DocObjects.CurveObject;
                Curve f = d.CurveGeometry;
                SetCurve(f);
            }
            else
            {
                Show();
                Btn_GetPlot_Copy1.Click += Btn_GetPlot_Copy1_Click;
                return;
            }


            //if (gcc.CommandResult() != Result.Success)
            //    return;
            //if (null == gcc.Object(0).Curve())
            //    return;

            //Curve boundary = gcc.Object(0).Curve();

            //SetCurve(boundary);



            //////자체구현 = 쓰레기 ////
            //    List<Point3d> points = new List<Point3d>();
            //    Point3d temp = Point3d.Unset;
            //    List<LineCurve> lines = new List<LineCurve>();
            //    Rhino.ApplicationSettings.ModelAidSettings.Osnap = true;
            //    List<System.Guid> guids = new List<System.Guid>();
            //    System.Guid mp = System.Guid.Empty;
            //    while(true)
            //    {

            //        var get = Rhino.Input.RhinoGet.GetPoint("select points", true, out temp);

            //        if (get != Result.Cancel)
            //        {
            //            points.Add(temp);

            //            if (points.Count >= 2)
            //            {
            //                LineCurve newline = new LineCurve(points[points.Count - 2], temp);
            //                lines.Add(newline);
            //                System.Guid newguid = RhinoDoc.ActiveDoc.Objects.AddCurve(newline);
            //                guids.Add(newguid);

            //            }

            //            if (points.Count > 2)
            //                if (points[0] == temp)
            //                {

            //                    break;

            //                }

            //        }


            //        else if(get == Result.Cancel) { break; }

            //        else if(get == Result.Nothing) { RhinoApp.WriteLine("zzz"); }
            //    }


            //    if (points.Count < 2)
            //        return;
            //    Curve[] joined = Curve.JoinCurves(lines);

            //    Rhino.ApplicationSettings.ModelAidSettings.Osnap = false;

            //    if (joined[0].IsClosed)
            //    {

            //        RhinoDoc.ActiveDoc.Objects.AddCurve(joined[0]);

            //        RhinoApp.Wait();

            //        SetCurve(joined[0]);
            //    }

            //    foreach (var c in guids)
            //    {
            //        RhinoDoc.ActiveDoc.Objects.Delete(c, true);
            //    }
        }
예제 #4
0
파일: utils.cs 프로젝트: cdriesler/natalus
        public static string makeDocBox()
        {
            try
            {
                //If docBox has not been created, create it and place it on its natalus layer.

                /* Abandoning layer idea for now. Not working as intended.
                 * Rhino.DocObjects.Layer layer_D10 = new Rhino.DocObjects.Layer();
                 * int layer_D10_index = -1;
                 *
                 * if (RhinoDoc.ActiveDoc.Layers.FindName("D10").Index < 0)
                 * {
                 *  RhinoDoc.ActiveDoc.Layers.Add(layer_D10);
                 *  layer_D10_index = layer_D10.Index;
                 * }
                 * else
                 * {
                 *  layer_D10 = RhinoDoc.ActiveDoc.Layers.FindName("D10");
                 *  layer_D10_index = layer_D10.Index;
                 * }
                 */

                //Set initial dimensions and record to D01 if D01 does not exist.
                string D01_Path = utils.file_structure.getPathFor("D01");
                string D20_Path = utils.file_structure.getPathFor("D20");

                double docBox_width  = 12;
                double docBox_height = 12;

                Rhino.Geometry.Point3d refPoint = new Rhino.Geometry.Point3d(0, 0, 0);

                //Check if previous dim configuration existed.
                if (System.IO.File.Exists(D01_Path) == true)
                {
                    string[] dims = System.IO.File.ReadAllText(D01_Path).Split('|');

                    docBox_width  = Convert.ToDouble(dims[0]);
                    docBox_height = Convert.ToDouble(dims[1]);
                }
                else
                {
                    System.IO.File.WriteAllText(D01_Path, "12|12");
                }

                double adjust = 0;

                if (System.IO.File.Exists(D20_Path) == true)
                {
                    string[] coords = System.IO.File.ReadAllText(D20_Path).Split(',');

                    refPoint.X = Convert.ToDouble(coords[0]);
                    refPoint.Y = Convert.ToDouble(coords[1]);

                    adjust = docBox_height;
                }
                else if (System.IO.File.Exists(D20_Path) == false)
                {
                    adjust = 0;
                }

                Rhino.Geometry.Plane docBox_plane = Rhino.Geometry.Plane.WorldXY;
                docBox_plane.OriginX = refPoint.X;
                docBox_plane.OriginY = refPoint.Y - adjust;

                Rhino.Geometry.Rectangle3d docBox = new Rhino.Geometry.Rectangle3d(docBox_plane, docBox_width, docBox_height);

                Rhino.DocObjects.ObjectAttributes docBox_attributes = new Rhino.DocObjects.ObjectAttributes();

                //Until layer process resolved, docBox to be on any layer.
                int activeIndex = RhinoDoc.ActiveDoc.Layers.CurrentLayerIndex;
                docBox_attributes.LayerIndex = activeIndex;

                //(Rhino 5) Convert docBox Rectangle3D to polyline curve.
                Rhino.Geometry.Polyline docBoxPolyline = docBox.ToPolyline();

                //Freeze updating while docBox is created.
                string x10_path = utils.file_structure.getPathFor("x10");
                System.IO.File.WriteAllText(x10_path, "false");

                //Determine GUID and record to D10.
                Guid newGuid = RhinoDoc.ActiveDoc.Objects.AddPolyline(docBoxPolyline);

                Rhino.DocObjects.ObjRef      docBoxObj   = new Rhino.DocObjects.ObjRef(newGuid);
                Rhino.DocObjects.CurveObject docBoxCurve = docBoxObj.Object() as Rhino.DocObjects.CurveObject;

                string docBoxGUID = newGuid.ToString();

                string D10_Path = utils.file_structure.getPathFor("D10");
                if (System.IO.File.Exists(D10_Path) && System.IO.File.ReadAllText(D10_Path) != "")
                {
                    string D11_Path = utils.file_structure.getPathFor("D11");
                    System.IO.File.WriteAllText(D11_Path, System.IO.File.ReadAllText(D10_Path));
                }
                System.IO.File.WriteAllText(D10_Path, docBoxGUID);

                //Set curve to Illustrator orange.
                System.Drawing.Color docBoxColor = System.Drawing.Color.FromArgb(240, 120, 6);

                docBoxCurve.Attributes.ColorSource      = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
                docBoxCurve.Attributes.ObjectColor      = docBoxColor;
                docBoxCurve.Attributes.PlotColorSource  = Rhino.DocObjects.ObjectPlotColorSource.PlotColorFromObject;
                docBoxCurve.Attributes.PlotColor        = docBoxColor;
                docBoxCurve.Attributes.PlotWeightSource = Rhino.DocObjects.ObjectPlotWeightSource.PlotWeightFromObject;
                docBoxCurve.Attributes.PlotWeight       = 1.5;

                docBoxCurve.CommitChanges();

                //Label it!
                Rhino.Geometry.TextEntity label = new Rhino.Geometry.TextEntity();

                label.TextHeight = .4;

                Rhino.Geometry.Plane label_plane = Rhino.Geometry.Plane.WorldXY;
                label_plane.OriginX = docBox_plane.OriginX;
                label_plane.OriginY = docBox_plane.OriginY - .4 - .1;
                label.Plane         = label_plane;

                label.Text = ("Linked Illustrator Artboard");

                Guid docBoxLabel = RhinoDoc.ActiveDoc.Objects.AddText(label);

                Rhino.DocObjects.ObjRef     labelObj  = new Rhino.DocObjects.ObjRef(docBoxLabel);
                Rhino.DocObjects.TextObject labelText = labelObj.Object() as Rhino.DocObjects.TextObject;

                labelText.Attributes.ColorSource     = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
                labelText.Attributes.ObjectColor     = docBoxColor;
                labelText.Attributes.PlotColorSource = Rhino.DocObjects.ObjectPlotColorSource.PlotColorFromObject;
                labelText.Attributes.PlotColor       = docBoxColor;

                labelText.CommitChanges();

                string docBoxLabelGUID = docBoxLabel.ToString();

                string D30_Path = utils.file_structure.getPathFor("D30");
                if (System.IO.File.Exists(D30_Path) && System.IO.File.ReadAllText(D30_Path) != "")
                {
                    string D31_Path = utils.file_structure.getPathFor("D31");
                    System.IO.File.WriteAllText(D31_Path, System.IO.File.ReadAllText(D30_Path));
                }
                System.IO.File.WriteAllText(D30_Path, docBoxLabelGUID);


                //Unfreeze updating.
                System.IO.File.WriteAllText(x10_path, "true");

                //Update illustrator boundaries.
                int    conversion = utils.units.conversion();
                string jsxPath    = utils.file_structure.getJavascriptPath();

                echo.interop echo = new echo.interop();
                echo.docBounds(docBox_width, System.Math.Abs(docBox_height), conversion, jsxPath);

                return(docBoxGUID);
            }
            catch (Exception e)
            {
                debug.alert(e.Message + " | " + e.Source);

                return("error");
            }
        }