.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to select all groups whitch the groupname contains 'PART-*'

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
swaywood
601 Views, 2 Replies

How to select all groups whitch the groupname contains 'PART-*'

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

2 REPLIES 2
Message 2 of 3
_gile
in reply to: swaywood

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;
        }

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3
swaywood
in reply to: swaywood

hi,gile:
thank you so much!
I'll try it.
best regards.
swaywood

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost