Anonymous groups can be created using the function “SetAt”, on the group dictionary. Please refer to the sample code shown below
[CommandMethod("creatAnonymGroup")]
public void creatAnonymGroup()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
PromptSelectionResult result = ed.GetSelection();
if (result.Status != PromptStatus.OK)
return;
using (Transaction Tx =
db.TransactionManager.StartTransaction())
{
DBDictionary groupDic =
(DBDictionary)Tx.GetObject(db.GroupDictionaryId,
OpenMode.ForWrite);
Group anonyGroup = new Group();
groupDic.SetAt("*", anonyGroup);
foreach (SelectedObject acSSObj in result.Value)
{
anonyGroup.Append(acSSObj.ObjectId);
}
//groupDic
Tx.AddNewlyCreatedDBObject(anonyGroup, true);
Tx.Commit();
}
}