设置透明度(2)auto CAD .NET二次开发

来源:互联网 发布:ps怎样制作淘宝详情页 编辑:程序博客网 时间:2024/04/30 03:44

设置透明度的方法2.

核心代码同上文。

 

 

 public bool SetDiaphaneity(double Mdiaphaneity, ObjectId[] EntityId)
        {
         
            bool setBool = false;
          
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            using (DocumentLock docLock = Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
              
                using (Database db = HostApplicationServices.WorkingDatabase)
                {
                    try
                    {
                        
                        using (Transaction trans = db.TransactionManager.StartTransaction())
                        {
                         
                            AddMaterial(Mdiaphaneity, "wood");

                            foreach (ObjectId obi in EntityId)
                            {
                            
                                Entity ent = trans.GetObject(obi, OpenMode.ForWrite) as Entity;
                           
                                ent.Material = "wood";
                          
                                this.Dispose(ent);
                            }
                        
                            trans.Commit();

                       
                            setBool = true;
                        }
                    }
                    finally
                    {
                      
                        this.Dispose(db);
                    }
                }
            }

           
            return setBool;
        }

如有问题请联系:qq1419226548

原创粉丝点击