Hi,
If your handle is a Handle object, you can use:
ObjectId id = Database.GetObjectId(false, handle, 0);
If your handle is a string convert the string into a long to create a new Handle object, then get the ObjectId:
long lg = Convert.ToInt64(handle, 16);
ObjectId id = Database.GetObjectId(false, new Handle(lg), 0)
EDIT: two safer methods
public ObjectId HandleToObjectId(string str, Database db)
{
long id;
if (Int64.TryParse(str, System.Globalization.NumberStyles.HexNumber, null, out id))
return HandleToObjectId(new Handle(id), db);
else
return ObjectId.Null;
}
public ObjectId HandleToObjectId(Handle handle, Database db)
{
try { return db.GetObjectId(false, handle, 0); }
catch { return ObjectId.Null; }
}