public static void smethod_0(ObjectId[] objectId_0, CoordinateSystem coordinateSystem_0) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database workingDatabase = HostApplicationServices.WorkingDatabase; ProgressMeter progressMeter = new ProgressMeter(); MessageFilter value = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(value); try { using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { progressMeter.SetLimit(objectId_0.Length); if ((double)objectId_0.Length > 10000.0) { progressMeter.Start("Computing min. perimeter rectangle..."); } CoordinateTransformator coordinateTransformator = new CoordinateTransformator(CoordinateSystem.Global(), coordinateSystem_0); CoordinateTransformator inverseTransformation = coordinateTransformator.GetInverseTransformation(); BlockTable blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1); ObjectId layerId = DBManager.CurrentLayerId(); DBManager.CurrentLayerName(); PointSet pointSet = new PointSet(); for (int i = 0; i < objectId_0.Length; i++) { progressMeter.MeterProgress(); DBPoint dBPoint = (DBPoint)transaction.GetObject(objectId_0[i], (OpenMode)0, true); Point point = new Point(dBPoint.Position.X, dBPoint.Position.Y, dBPoint.Position.Z); coordinateTransformator.Transform(point); pointSet.Add(point); } ConvexHull2d convexHull2d = new ConvexHull2d(); convexHull2d.InitialPoints = pointSet; convexHull2d.ComputeHull(); PointSet vertices = convexHull2d.Vertices; double z = vertices[0].Z; for (int j = 0; j < vertices.Count; j++) { vertices[j].Z = z; } BoundingRectangle boundingRectangle = convexHull2d.MinimumPerimeterEnclosingRectangle(); PointSet vertices2 = boundingRectangle.GetVertices(); for (int k = 0; k < vertices2.Count; k++) { inverseTransformation.Transform(vertices2[k]); } Point3dCollection point3dCollection = Conversions.ToPoint3dCollection(vertices2.ToList()); Polyline3d polyline3d = new Polyline3d(0, point3dCollection, true); polyline3d.LayerId = (layerId); blockTableRecord.AppendEntity(polyline3d); transaction.AddNewlyCreatedDBObject(polyline3d, true); editor.WriteMessage("\nMinimum perimeter enclosing rectangle properties:"); editor.WriteMessage("\n-------------------------------------------------"); editor.WriteMessage("\nWidth : " + boundingRectangle.Width.ToString(DBManager.GetFormatFromLUPREC())); editor.WriteMessage("\nHeight : " + boundingRectangle.Length.ToString(DBManager.GetFormatFromLUPREC())); editor.WriteMessage("\nArea : " + (boundingRectangle.Length * boundingRectangle.Width).ToString(DBManager.GetFormatFromLUPREC())); editor.WriteMessage("\nPerimeter length: " + (2.0 * boundingRectangle.Length + 2.0 * boundingRectangle.Width).ToString(DBManager.GetFormatFromLUPREC())); transaction.Commit(); } progressMeter.Stop(); } catch (System.Exception ex) { progressMeter.Stop(); throw; } }