Ejemplo n.º 1
0
        private void method_1(ObjectId[] objectId_0, double double_1, ref int int_1, ref int int_2, ref int int_3)
        {
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            Editor        arg_15_0        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ProgressMeter progressMeter   = new ProgressMeter();
            MessageFilter messageFilter   = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(messageFilter);
            progressMeter.SetLimit(objectId_0.Length);
            progressMeter.Start("Simplifying polylines");
            try
            {
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                    BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                    for (int i = 0; i < objectId_0.Length; i++)
                    {
                        try
                        {
                            progressMeter.MeterProgress();
                            messageFilter.CheckMessageFilter((long)i, 10);
                            DBObject @object  = transaction.GetObject(objectId_0[i], (OpenMode)1);
                            bool     flag     = false;
                            Polyline polyline = @object as Polyline;
                            if (polyline != null)
                            {
                                flag = polyline.Closed;
                            }
                            Polyline2d polyline2d = @object as Polyline2d;
                            if (polyline2d != null)
                            {
                                flag = polyline2d.Closed;
                            }
                            Polyline3d polyline3d = @object as Polyline3d;
                            if (polyline3d != null)
                            {
                                flag = polyline3d.Closed;
                            }
                            List <ngeometry.VectorGeometry.Point> p = PointGeneration.SubdividePolyline(@object, transaction, 0.0).ToList();
                            int_1 += Conversions.GetNumberOfPoyllineVertices(@object);
                            List <ngeometry.VectorGeometry.Point> list = this.method_2(p, double_1);
                            int_2 += list.Count;
                            Point3dCollection point3dCollection = Conversions.ToPoint3dCollection(list);
                            Polyline3d        polyline3d2       = new Polyline3d(0, point3dCollection, flag);
                            polyline3d2.SetPropertiesFrom((Entity)@object);
                            if (PLine.string_2 == "N" & [email protected])
                            {
                                @object.Erase();
                            }
                            blockTableRecord.AppendEntity(polyline3d2);
                            transaction.AddNewlyCreatedDBObject(polyline3d2, true);
                        }
                        catch (System.Exception ex)
                        {
                            int_3++;
                        }
                    }
                    transaction.Commit();
                }
                progressMeter.Stop();
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                throw ex;
            }
        }