I am trying to write a method that prompts the user to select a group and returns the ObjectId of the group, so I can use it later. Now this method is as follows:
public static ObjectId PromptUserForGroup()
{
using (Transaction tr = _database.TransactionManager.StartTransaction())
using (DocumentLock docLock = _activeDocument.LockDocument())
{
PromptSelectionResult activeSelectionPrompt = _editor.GetSelection();
if (activeSelectionPrompt.Status == PromptStatus.OK)
{
ObjectId[] ids = activeSelectionPrompt.Value.GetObjectIds();
foreach (ObjectId id in ids)
{
Group groupToCheck = tr.GetObject(id, OpenMode.ForWrite) as Group;
if (groupToCheck != null)
{
return groupToCheck.Id;
}
}
}
else
{
throw new IOException();
}
return ObjectId.Null;
}
}
When I call the method, it asks the user how I want it. However, when I select a group, it always returns ObjectId.Null means that I do not understand that I select a group. I do not know what is wrong or how to fix it.
source
share