C# 分形几何图

 [CommandMethod("FenXingShu")]
        public void FenXingShu()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Random k_r = new Random();
            int i;
            double x = 0, y = 0, r, u = 0;
            List<Entity> ents = new List<Entity>();
            for (i = 0; i <= 10000; i++)
            {
                r = (int)(k_r.NextDouble() * 100);
                if (r < 1)
                {
                    x = 0;
                    y = .16 * y;
                }
                if (r >= 1  && r < 86)
                {
                    u = .85 * x + .04 * y;
                    y = -0.04 * x + 0.85 * y + 1.6;
                    x = u;
                }
                if (r >= 86 && r < 93)
                {
                    u = .2 * x - .26 * y;
                    y = .23 * x + .22 * y + 1.6;
                    x = u;
                }
                if (r >= 93)
                {
                    u = -.15 * x + .28 * y;
                    y = .26 * x + .24 * y + .44;
                    x = u;
                }
                DBPoint dBPoint =new DBPoint(new Point3d(40 * x + 120, 40 * y, 0));
                
                ents.Add(dBPoint);
            }
            db.AddToModelSpace(ents);
        }

 /// <summary>
        /// 将实体添加到模型空间
        /// </summary>
        /// <param name="db">数据库对象</param>
        /// <param name="ents">要添加的多个实体</param>
        /// <returns>返回添加到模型空间中的实体ObjectId集合</returns>
        public static ObjectIdCollection AddToModelSpace(this Database db, params Entity[] ents)
        {
            ObjectIdCollection ids = new ObjectIdCollection();
            
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                foreach (var ent in ents)
                {
                    ids.Add(btr.AppendEntity(ent));
                    trans.AddNewlyCreatedDBObject(ent, true);
                }
                btr.DowngradeOpen();
                trans.Commit();
            }            
            return ids;
        }

        /// <summary>
        /// 将实体添加到模型空间
        /// </summary>
        /// <param name="db">数据库对象</param>
        /// <param name="ents">要添加的实体列表</param>
        /// <returns>返回添加到模型空间中的实体ObjectId集合</returns>
        public static ObjectIdCollection AddToModelSpace(this Database db, List<Entity> ents)
        {
            ObjectIdCollection ids = new ObjectIdCollection();
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                foreach (var ent in ents)
                {
                    ids.Add(btr.AppendEntity(ent));
                    trans.AddNewlyCreatedDBObject(ent, true);
                }
                btr.DowngradeOpen();
                trans.Commit();
            }
            return ids;
        }