明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2451|回复: 7

[符号表] 求助 如何改组实体的颜色

[复制链接]
发表于 2010-11-10 10:57 | 显示全部楼层 |阅读模式

Point(一个点和三个圆)组成一个组。用过滤集选择点,给选择过的point做个标记,说明已经操作过了,我想让它改变颜色!!!怎么能给这个组的实体改变颜色呢???

发表于 2010-11-10 18:11 | 显示全部楼层
先按实体获取所在的组:
参考
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=78963
http://www.objectarx.net/forum.php?mod=viewthread&tid=6018&extra=page%3D1
  1. using System;
  2. using System.Linq;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using Autodesk.AutoCAD.DatabaseServices;
  6. using Autodesk.AutoCAD.Internal;
  7. using Autodesk.AutoCAD.Runtime;
  8. namespace TlsCad.ExtendMethods
  9. {
  10.     public static class EntityEx
  11.     {
  12.         //Acad2009及以后版本调用
  13.         public static IEnumerable<ObjectId> GetGroupIds(this Entity ent)
  14.         {
  15.             ObjectIdCollection ids = ent.GetPersistentReactorIds();
  16.             if (ids != null && ids.Count > 0)
  17.             {
  18.                 RXClass rxclass = RXClass.GetClass(typeof(Group));
  19.                 return
  20.                     ids.Cast<ObjectId>()
  21.                     .Where(id => id.ObjectClass.IsDerivedFrom(rxclass));
  22.             }
  23.             return Enumerable.Empty<ObjectId>();
  24.         }
  25.         //Acad2009以前版本调用
  26.         public static IEnumerable<Group> GetGroups(this Entity ent, Transaction tr)
  27.         {
  28.             ObjectIdCollection ids = ent.GetPersistentReactorIds();
  29.             if (ids != null && ids.Count > 0)
  30.             {
  31.                 foreach (ObjectId id in ids)
  32.                 {
  33.                     Group g = tr.GetObject(id, OpenMode.ForRead) as Group;
  34.                     if (g != null)
  35.                         yield return g;
  36.                 }
  37.             }
  38.         }
  39. }
 楼主| 发表于 2010-11-11 08:40 | 显示全部楼层

//Acad2009及以后版本调用

return ids.Cast<ObjectId>() .Where(id => id.ObjectClass.IsDerivedFrom(rxclass));

ids.Cast<ObjectId>()是什么?怎么没有相应的函数啊?

发表于 2010-11-11 17:39 | 显示全部楼层

这个是Linq的语法,VS要2008版本的

 楼主| 发表于 2010-11-12 11:32 | 显示全部楼层

我们用的都是vs2005版本的。没有那个方法!!!!哇哇哇......

发表于 2010-11-12 11:49 | 显示全部楼层
那就
  1.         public static List<ObjectId> GetGroupIds2(Entity ent)
  2.         {
  3.             ObjectIdCollection ids = ent.GetPersistentReactorIds();
  4.             if (ids != null && ids.Count > 0)
  5.             {
  6.                 RXClass rxclass = RXClass.GetClass(typeof(Group));
  7.                 List<ObjectId> res = new List<ObjectId>();
  8.                 foreach (ObjectId id in ids)
  9.                 {
  10.                     if (id.ObjectClass.IsDerivedFrom(rxclass))
  11.                         res.Add(id);
  12.                 }
  13.                 return res;
  14.             }
  15.             return null;
  16.         }
复制代码
 楼主| 发表于 2010-11-17 10:00 | 显示全部楼层
List<group> gp=GetGroups(pt);//获取组名 ObjectId[] entId = gp[0].GetAllEntityIds(); for (int i= 0; i &lt; entId.Length;i++ ) { Entity entsel = (Entity)trans.GetObject(entId, OpenMode.ForWrite); entsel.ColorIndex = 5; } 这样就改变了一组实体的颜色了!!!呵呵...好久没有看了谢谢.
发表于 2011-5-12 15:45 | 显示全部楼层
cad06下面怎么获取实体所在的组啊?????????、
06没有这个GetPersistentReactorIds()方法!!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-25 23:07 , Processed in 0.176788 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表