/// <summary>
/// Gets all objectIDs in the drawing with the specified appname written to it's xData.
/// </summary>
/// <param name="appName">Name of the appName to filter for</param>
/// <param name="modelspaceOnly">Only select objects in modelspace</param>
/// <returns></returns>
public static ObjectIdCollection GetAllObjectIDs(string appName, bool modelspaceOnly = true)
{
string frozenLayers;
using (var tr
= new OpenCloseTransaction
()) {
var layerTable = (LayerTable)tr.GetObject(Active.Database.LayerTableId, OpenMode.ForRead);
frozenLayers = string.Join(",",
layerTable.Cast<ObjectId>()
.Select(id => (LayerTableRecord)tr.GetObject(id, OpenMode.ForRead))
.Where(l => l.IsFrozen)
.Select(l => l.Name));
tr.Commit();
}
ObjectIdCollection result
= new ObjectIdCollection
(); TypedValueList filterArray
= new TypedValueList
() {
new TypedValue
((int)DxfCode
.ExtendedDataRegAppName, appName
) };
if (!string.IsNullOrEmpty(frozenLayers))
{
filterArray
.Add(new TypedValue
(-4,
"<NOT")); filterArray
.Add(new TypedValue
(8, frozenLayers
)); filterArray
.Add(new TypedValue
(-4,
"NOT>")); }
if (modelspaceOnly
) filterArray
.Add(new TypedValue
(67,
0)); SelectionFilter appNameFilter
= new SelectionFilter
(filterArray
); PromptSelectionResult psr = Active.Editor.SelectAll(appNameFilter);
if (psr.Status == PromptStatus.OK)
{
return new ObjectIdCollection
(psr
.Value.GetObjectIds()); }
return result;
}