...
ObjectId groupId = dbDic.Value;
...
[code]
static public void GetGroupNames()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
DBDictionary lt = (DBDictionary) trans.GetObject(db.GroupDictionaryId, OpenMode.ForRead);
foreach (DictionaryEntry ide in lt)
{
Group ltr = (Group) trans.GetObject((ObjectId)ide.Value, OpenMode.ForRead);
ed.WriteMessage("\nGroup Name: {0}",ltr.Name);
}
trans.Commit();
}
finally
{
trans.Dispose();
}
}
[/code]
Next code also can be useful for you:
[code]
//
// Return ArrayList of ObjectId for all groups
//
static private ArrayList GetAllGroupsIds()
{
ArrayList ids = new ArrayList();
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
DBDictionary lt = (DBDictionary) trans.GetObject(db.GroupDictionaryId, OpenMode.ForRead);
foreach (DictionaryEntry ide in lt) ids.Add(ide.Value);
trans.Commit();
}
finally
{
trans.Dispose();
}
return ids;
}
//
// Print names of all groups of selected entity
//
[CommandMethod("PrintGroupNamesOfEntity")]
static public void PrintGroupNamesOfEntity()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
try
{
ArrayList groupIds = GetAllGroupsIds();
if (groupIds.Count == 0) {
ed.WriteMessage("\nDrawing has not any group!");
return;
}
PromptEntityResult entres = ed.GetEntity("\nSelect entity: ");
if (entres.Status == PromptStatus.OK)
{
Entity en = (Entity) trans.GetObject(entres.ObjectId, OpenMode.ForRead);
foreach (ObjectId id in groupIds)
{
if (en.HasPersistentReactor(id))
{
Group gr = (Group) trans.GetObject(id, OpenMode.ForRead);
ed.WriteMessage("\nGroup Name: {0}",gr.Name);
}
}
}
trans.Commit();
}
finally
{
trans.Dispose();
}
}
[/code]
Message was edited by: Alexander Rivilis