TrustedDWG is a key function of AutoCAD and AutoCAD LT that analyses DWG files as they are being opened. The function checks to see if the DWG file was last saved with an Autodesk product or by a software developer who is licensed to use the RealDWG toolkit. If the file does not pass the TrustedDWG analysis, it will inform you in various ways that the DWG file may not be compatible, nor guarantee its integrity when used with AutoCAD or AutoCAD LT.
The visibility of these warnings is controlled by the DWGCHECK system variable. DWGCHECK is an integer variable, and is saved in the registry
When a drawing is not a TrustedDWG, and you open the drawing in AutoCAD or LT, you get this message or pop dialog.
Non Autodesk DWG. This DWG file was saved by a software application that was not developed or licensed by Autodesk. Autodesk cannot guarantee the application compatibility or integrity of this file.
Using API DwgFileWasSavedByAutodeskSoftware
public void IsTrustedDWG() { Document doc = CoreApp.DocumentManager.MdiActiveDocument; if (doc == null) return; Editor ed = doc.Editor; var presult = ed.GetString(new PromptStringOptions("Enter Drawing File Path")); if (presult.Status != PromptStatus.OK) return; var db = HostApplicationServices.WorkingDatabase; Database sideDb = new Database(false, true); sideDb.ReadDwgFile(presult.StringResult, System.IO.FileShare.Read, true, null); HostApplicationServices.WorkingDatabase = sideDb; bool isTrustedDWG = sideDb.DwgFileWasSavedByAutodeskSoftware; if (isTrustedDWG) { ed.WriteMessage("Is Trusted DWG\n"); } HostApplicationServices.WorkingDatabase = db; }
Recent Comments