zoukankan      html  css  js  c++  java
  • 如何把一个对象的颜色设置成 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;
    }
    
    作者:峻祁连
    邮箱:junqilian@163.com
    出处:http://junqilian.cnblogs.com
    转载请保留此信息。
  • 相关阅读:
    BZOJ 4033: [HAOI2015]树上染色 (树形DP)
    BZOJ 1820: [JSOI2010]Express Service 快递服务 DP
    BZOJ 4664: Count 插块DP
    BZOJ 1899: [Zjoi2004]Lunch 午餐 DP
    BZOJ 4559 [JLoi2016]成绩比较 (DP+拉格朗日插值)
    BZOJ1485 [HNOI2009] 有趣的数列 (卡特兰数)
    BZOJ 2111 / Luogu P2606 [ZJOI2010]排列计数
    20190915模拟赛
    深海机器人问题
    太空飞行计划问题
  • 原文地址:https://www.cnblogs.com/junqilian/p/2164084.html
Copyright © 2011-2022 走看看