/// <summary>
/// Given a handle, return an associated ObjectId
/// </summary>
/// <param name="handle">The handle.</param>
/// <returns>the required ObjectId or ObjectId.Null</returns>
public static ObjectId GetObjectIDFromHandle(string handle)
{
if (handle.Length < 3) return ObjectId.Null;
try
{
// Convert hexadecimal string to 64-bit
long ln = Convert.ToInt64(handle, 16);
// Now create a Handle from the long integer
Handle hn
= new Handle
(ln
); // And attempt to get an ObjectId for the Handle
ObjectId id =Active.Database.GetObjectId(false,hn,0);
// return the objectID if it exists, ObjectId.Null if it doesn't
if (id.IsEffectivelyErased || id.IsErased) return ObjectId.Null;
return id;
}
catch
{
return ObjectId.Null;
}
}