日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

如何把一个对象的颜色设置成 ByLayer

發布時間:2023/12/31 综合教程 30 生活家
生活随笔 收集整理的這篇文章主要介紹了 如何把一个对象的颜色设置成 ByLayer 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

AutoCAD .net API中可以用如下代碼來設置entity的顏色為bylayer,請注意 BYLAYER的colorIndex為256。很簡單,光貼代碼。

 [CommandMethod("SetColorByLayer")]
public void SetColorByLayer()
{
ObjectId objId = GetSelectEntity();
using (Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
{
Entity ent = trans.GetObject(objId, OpenMode.ForWrite) as Entity;
//the corlor index of "BYLAYER" is 256, "BYBLOCK" is 0
ent.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, 256);
trans.Commit();
}
}
private ObjectId GetSelectEntity()
{
ObjectId oid = ObjectId.Null;
using (DocumentLock docLoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
{
PromptEntityOptions selectionOp = new PromptEntityOptions("\nselect entity");
PromptEntityResult prRes = ed.GetEntity(selectionOp);
if (prRes.Status == PromptStatus.OK)
{
oid = prRes.ObjectId;
}
}
return oid;
}

.csharpcode, .csharpcode pre { font-size: small; color: rgba(0, 0, 0, 1); font-family: consolas, "Courier New", courier, monospace; background-color: rgba(255, 255, 255, 1) }
.csharpcode pre { margin: 0 }
.csharpcode .rem { color: rgba(0, 128, 0, 1) }
.csharpcode .kwrd { color: rgba(0, 0, 255, 1) }
.csharpcode .str { color: rgba(0, 96, 128, 1) }
.csharpcode .op { color: rgba(0, 0, 192, 1) }
.csharpcode .preproc { color: rgba(204, 102, 51, 1) }
.csharpcode .asp { background-color: rgba(255, 255, 0, 1) }
.csharpcode .html { color: rgba(128, 0, 0, 1) }
.csharpcode .attr { color: rgba(255, 0, 0, 1) }
.csharpcode .alt { background-color: rgba(244, 244, 244, 1); 100%; margin: 0 }
.csharpcode .lnum { color: rgba(96, 96, 96, 1) }

作者:峻祁連
郵箱:junqilian@163.com
出處:http://junqilian.cnblogs.com
轉載請保留此信息。

總結

以上是生活随笔為你收集整理的如何把一个对象的颜色设置成 ByLayer的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。