求助 如何改组实体的颜色
<p>Point(一个点和三个圆)组成一个组。用过滤集选择点,给选择过的point做个标记,说明已经操作过了,我想让它改变颜色!!!怎么能给这个组的实体改变颜色呢???</p> 先按实体获取所在的组:参考
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=78963
http://www.objectarx.net/forum.php?mod=viewthread&tid=6018&extra=page%3D1
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Internal;
using Autodesk.AutoCAD.Runtime;
namespace TlsCad.ExtendMethods
{
public static class EntityEx
{
//Acad2009及以后版本调用
public static IEnumerable<ObjectId> GetGroupIds(this Entity ent)
{
ObjectIdCollection ids = ent.GetPersistentReactorIds();
if (ids != null && ids.Count > 0)
{
RXClass rxclass = RXClass.GetClass(typeof(Group));
return
ids.Cast<ObjectId>()
.Where(id => id.ObjectClass.IsDerivedFrom(rxclass));
}
return Enumerable.Empty<ObjectId>();
}
//Acad2009以前版本调用
public static IEnumerable<Group> GetGroups(this Entity ent, Transaction tr)
{
ObjectIdCollection ids = ent.GetPersistentReactorIds();
if (ids != null && ids.Count > 0)
{
foreach (ObjectId id in ids)
{
Group g = tr.GetObject(id, OpenMode.ForRead) as Group;
if (g != null)
yield return g;
}
}
}
}
<p>//Acad2009及以后版本调用</p>
<p>return ids.Cast<ObjectId>() .Where(id => id.ObjectClass.IsDerivedFrom(rxclass));</p>
<p>ids.Cast<ObjectId>()是什么?怎么没有相应的函数啊?</p> <p>这个是Linq的语法,VS要2008版本的</p> <p>我们用的都是vs2005版本的。没有那个方法!!!!哇哇哇......</p> 那就
public static List<ObjectId> GetGroupIds2(Entity ent)
{
ObjectIdCollection ids = ent.GetPersistentReactorIds();
if (ids != null && ids.Count > 0)
{
RXClass rxclass = RXClass.GetClass(typeof(Group));
List<ObjectId> res = new List<ObjectId>();
foreach (ObjectId id in ids)
{
if (id.ObjectClass.IsDerivedFrom(rxclass))
res.Add(id);
}
return res;
}
return null;
}
List<group> gp=GetGroups(pt);//获取组名 ObjectId[] entId = gp.GetAllEntityIds(); for (int i= 0; i < entId.Length;i++ ) { Entity entsel = (Entity)trans.GetObject(entId, OpenMode.ForWrite); entsel.ColorIndex = 5; } 这样就改变了一组实体的颜色了!!!呵呵...好久没有看了谢谢. cad06下面怎么获取实体所在的组啊?????????、
06没有这个GetPersistentReactorIds()方法!!!!!
页:
[1]