Hi all:
in a drawing there are many groups.
the group name just like 'PART-1','PART-2','PART-…'
can i use a filter to select all the groups at ont time?
I am new, could you kindly give me some code to learn how to do that?
best regards
swaywood
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Hi,
You can't use a selection filter, but you can get the ObjectIdS of the entities within the groups which names match a specified pattern.
SelectByGroupName(db, "PART-*");
private ObjectIdCollection SelectByGroupName(Database db, string pattern) { ObjectIdCollection result = new ObjectIdCollection(); using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction()) { DBDictionary NOD = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead); DBDictionary groups = (DBDictionary)tr.GetObject(NOD.GetAt("ACAD_GROUP"), OpenMode.ForRead); foreach (DBDictionaryEntry entry in groups) { if (Utils.WcMatchEx(entry.Key, pattern, true)) { Group group = (Group)tr.GetObject(entry.Value, OpenMode.ForRead); foreach (ObjectId id in group.GetAllEntityIds()) { result.Add(id); } } } tr.Commit(); } return result; }