乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 49|回复: 2

[求助]指定图层颜色的问题

[复制链接]

14

主题

49

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2010-8-8 21:48:00 | 显示全部楼层 |阅读模式
红色的这一句是用了“配色系统”中的颜色,应该是黄色的,那么第三个图层"ColorBookYellow"应该是黄色,为什么程序运行之后是白色的呢?
代码来自“ .NET 开发人员手册”的“”
  1. [CommandMethod("SetLayerColor")]public static void SetLayerColor(){  // Get the current document and database  Document acDoc = Application.DocumentManager.MdiActiveDocument;  Database acCurDb = acDoc.Database;   // Start a transaction  using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())  {      // Open the Layer table for read      LayerTable acLyrTbl;      acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId,                                   OpenMode.ForRead) as LayerTable;       // Define an array of layer names      string[] sLayerNames = new string[3];      sLayerNames[0] = "ACIRed";      sLayerNames[1] = "TrueBlue";      sLayerNames[2] = "ColorBookYellow";       // Define an array of colors for the layers      Color[] acColors = new Color[3];      acColors[0] = Color.FromColorIndex(ColorMethod.ByAci, 1);      acColors[1] = Color.FromRgb(23, 54, 232);      acColors[2] = Color.FromNames("PANTONE Yellow 0131 C",                                    "PANTONE(R) pastel coated");       int nCnt = 0;       // Add or change each layer in the drawing      foreach (string sLayerName in sLayerNames)      {          LayerTableRecord acLyrTblRec;           if (acLyrTbl.Has(sLayerName) == false)          {              acLyrTblRec = new LayerTableRecord();               // Assign the layer a name              acLyrTblRec.Name = sLayerName;               // Upgrade the Layer table for write              if (acLyrTbl.IsWriteEnabled == false) acLyrTbl.UpgradeOpen();               // Append the new layer to the Layer table and the transaction              acLyrTbl.Add(acLyrTblRec);              acTrans.AddNewlyCreatedDBObject(acLyrTblRec, true);          }          else          {              // Open the layer if it already exists for write              acLyrTblRec = acTrans.GetObject(acLyrTbl[sLayerName],                                              OpenMode.ForWrite) as LayerTableRecord;          }           // Set the color of the layer          acLyrTblRec.Color = acColors[nCnt];           nCnt = nCnt + 1;      }       // Save the changes and dispose of the transaction      acTrans.Commit();  }}
回复

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2010-8-8 22:31:00 | 显示全部楼层
代码在Cad2010正常,2008失败
应该是2008的类库的问题吧
回复

使用道具 举报

14

主题

49

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2010-8-8 23:02:00 | 显示全部楼层
老大,我的CAD2007也不行,算了,跳过这地方了
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-29 03:44 , Processed in 1.582317 second(s), 59 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表