コード例 #1
0
ファイル: PLine_1.cs プロジェクト: 1833183060/autocad-dev
        private void method_0(ObjectId[] objectId_0)
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            Global.SuspendEpsilon(0.0, 0.0);
            try
            {
                List <Edge> unorderedEdges = Conversions.ToCeometricCADDataEdgeList(objectId_0);
                int         num            = 0;
                int         num2           = 0;
                int         num3           = 0;
                bool        eliminateZeroLengthSegments = true;
                if (PLine_1.string_1.Trim().ToUpper() == "N")
                {
                    eliminateZeroLengthSegments = false;
                }
                PLine_1.ConstructFromUnorderedSegments(unorderedEdges, PLine_1.int_0, ref num2, ref num, ref num3, true, true, eliminateZeroLengthSegments);
                if (PLine_1.string_0 == "Y")
                {
                    DBManager.EraseObjects(objectId_0, 100000);
                }
                editor.WriteMessage("\nNumber of segments added      : " + num.ToString());
                editor.WriteMessage("\nNumber of zero-length segments: " + num3.ToString());
                editor.WriteMessage("\nNumber of polylines generated : " + num2.ToString());
                Global.ResumeEpsilon();
            }
            catch (System.Exception ex)
            {
                Global.ResumeEpsilon();
                editor.WriteMessage("\n" + ex.Message);
            }
        }
コード例 #2
0
ファイル: PLine_1.cs プロジェクト: 1833183060/autocad-dev
        public static void WriteInDatabase(PLine_1 pline)
        {
            Editor   arg_0F_0        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database workingDatabase = HostApplicationServices.WorkingDatabase;

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                BlockTable       blockTable                = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)0);
                BlockTableRecord blockTableRecord          = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                List <ngeometry.VectorGeometry.Point> list = pline.GetVertices().ToList();
                if (pline.IsClosed)
                {
                    list.RemoveAt(list.Count - 1);
                }
                Point3dCollection point3dCollection = Conversions.ToPoint3dCollection(list);
                Polyline3d        polyline3d        = new Polyline3d(0, point3dCollection, false);
                point3dCollection.Dispose();
                if (pline.IsClosed)
                {
                    polyline3d.Closed = (true);
                }
                bool flag = false;
                polyline3d.LayerId = (DBManager.CreateLayer(pline.CADData.Layer.Name, 7, false, ref flag));
                Autodesk.AutoCAD.Colors.Color color = null;
                short colorIndex = pline.CADData.ColorIndex;
                if (pline.CADData.Color != System.Drawing.Color.Empty)
                {
                    color = Autodesk.AutoCAD.Colors.Color.FromColor(pline.CADData.Color);
                }
                if (color == null)
                {
                    polyline3d.ColorIndex = ((int)colorIndex);
                }
                else
                {
                    polyline3d.Color = (color);
                }
                blockTableRecord.AppendEntity(polyline3d);
                transaction.AddNewlyCreatedDBObject(polyline3d, true);
                transaction.Commit();
            }
        }
コード例 #3
0
ファイル: PLine_1.cs プロジェクト: 1833183060/autocad-dev
        public static List <PLine_1> ConstructFromUnorderedSegments(List <Edge> unorderedEdges, int relevantDecimals, ref int numberOfPLines, ref int numberOfSegments, ref int zeroLength, bool writeDatabase, bool useProgressMeter, bool eliminateZeroLengthSegments)
        {
            Editor        arg_0F_0      = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ProgressMeter progressMeter = new ProgressMeter();
            MessageFilter messageFilter = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(messageFilter);
            List <PLine_1> list = new List <PLine_1>();

            PLine_1.edgeVertexList = new EdgeVertexList();
            if (useProgressMeter)
            {
                ProgressMeter arg_44_0 = progressMeter;
                int           arg_44_1 = unorderedEdges.Count;
                int           arg_43_0 = unorderedEdges.Count;
                arg_44_0.SetLimit(arg_44_1);
            }
            if (useProgressMeter)
            {
                progressMeter.Start("Processing lines");
            }
            List <PLine_1> result;

            try
            {
                //"0." + "".PadLeft(relevantDecimals, '0');
                for (int i = 0; i < unorderedEdges.Count; i++)
                {
                    if (useProgressMeter && i % 100 == 0)
                    {
                        progressMeter.MeterProgress();
                    }
                    Edge edge = unorderedEdges[i];
                    edge.Round(relevantDecimals);
                    PLine_1.edgeVertexList.Add(edge);
                }
                for (int j = 0; j < unorderedEdges.Count; j++)
                {
                    if (useProgressMeter)
                    {
                        progressMeter.MeterProgress();
                    }
                    messageFilter.CheckMessageFilter((long)j, 100);
                    if (unorderedEdges[j].Status == Edge.EdgeStatus.NotDefined)
                    {
                        PLine_1 pLine = new PLine_1();
                        pLine.caddata_0 = unorderedEdges[j].CADData;
                        List <Edge> list2 = PLine_1.smethod_0(unorderedEdges[j]);
                        pLine.AddRange(list2);
                        pLine.Add(unorderedEdges[j]);
                        unorderedEdges[j].Status = Edge.EdgeStatus.NotDefined;
                        List <Edge> list3 = PLine_1.smethod_1(unorderedEdges[j]);
                        pLine.AddRange(list3);
                        double num  = Math.Pow(10.0, (double)(-(double)relevantDecimals));
                        int    num2 = 0;
                        if (pLine.Count == 1 && pLine[0].Length < num)
                        {
                            zeroLength++;
                            num2++;
                            if (eliminateZeroLengthSegments)
                            {
                                goto IL_231;
                            }
                        }
                        else
                        {
                            for (int k = pLine.Count - 2; k >= 0; k--)
                            {
                                if (pLine[k].Length < num)
                                {
                                    if (eliminateZeroLengthSegments)
                                    {
                                        pLine[k + 1].StartPoint = pLine[k].StartPoint;
                                        pLine.RemoveAt(k);
                                    }
                                    zeroLength++;
                                    num2++;
                                }
                            }
                        }
                        if (pLine.Count != 0)
                        {
                            list.Add(pLine);
                            if (!eliminateZeroLengthSegments)
                            {
                                num2 = 0;
                            }
                            numberOfSegments += list2.Count + list3.Count - num2 + 1;
                            numberOfPLines++;
                            if (writeDatabase)
                            {
                                PLine_1.WriteInDatabase(pLine);
                            }
                        }
                    }
                    IL_231 :;
                }
                if (useProgressMeter)
                {
                    progressMeter.Stop();
                }
                result = list;
            }
            catch (System.Exception ex)
            {
                if (useProgressMeter)
                {
                    progressMeter.Stop();
                }
                throw;
            }
            return(result);
        }