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
    转载请保留此信息。
  • 相关阅读:
    ExquisiteWnd
    GDIPlusEncapsulation
    COleDateTimeSpan
    Create Win32 Window
    vagrant 安装配置,PhpStorm10 设置远程调试
    PHPExcel导出主要代码记录
    常用js方法集合,动态加载js方法--判断变量是否为空--截取小数点后几位--截取带中文的字条串
    最近遇到的各种坑
    控制台运行bee run project 报[ERRO] Fail to watch directory[too many open files]
    Mac 安装beego And bee工具
  • 原文地址:https://www.cnblogs.com/junqilian/p/2164084.html
Copyright © 2011-2022 走看看