By Augusto Goncalves (@augustomaia)
It’s possible to check if a drawing was created using Civil 3D by checking its Named Objects Dictionary for a ‘root’ key, as demonstrated by Isaac at this blog post. Now we want the same for Autodesk Utility Design, is it possible?
Indeed the same approach should work, just need to check for a different key, in this case UUDMDICTIONARY. There is also one additional step, check for “Configuration:RUS” custom property on the drawing.
The following code sample demonstrate this approach. It can be used as an extension method for Database.
public static bool IsAUDDatabase(this Database db)
{
using (Transaction trans = db.TransactionManager.StartOpenCloseTransaction())
{
// must have this NOD key
DBDictionary namedObjectDict = trans.GetObject(db.NamedObjectsDictionaryId,
OpenMode.ForRead) as DBDictionary;
if (!namedObjectDict.Contains("UUDMDICTIONARY")) return false;
// must also have a "Configuration:RUS" custom property
IDictionaryEnumerator summary = db.SummaryInfo.CustomProperties;
while (summary.MoveNext())
{
if (summary.Key.ToString().Equals("CONFIGURATION", StringComparison.OrdinalIgnoreCase) &&
summary.Value.ToString().Equals("RUS", StringComparison.OrdinalIgnoreCase))
return true; // found it!
}
return false;
}
}