Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying read a template file (.dwt) into a freshly created drawing. The ReadDwgFile files with eRepeatedDwgRead even though nothing has ever been read into this db before. How can I get this file read into my DB?
public static void LoadTemplate()
{
Logging.AddLog("Loading kb Drawing Template.");
string baseTemplateUrl = ""; //redacted for forum;
// Get the temp file name for the base template
string baseLocalFilePath = Path.Combine(Path.GetTempPath(), GetURLBasePath(baseTemplateUrl) + ".dwg");
try
{
using (WebClient client = new WebClient())
{
// Download the base template file from the URL to the local file path
try
{
client.DownloadFile(baseTemplateUrl, baseLocalFilePath);
}
catch (System.Exception e)
{
Logging.AddLog($"Could not download the kB base template url:\n{e}", "error");
return;
}
// Read the base template into the dwg db
try
{
KbCadHostAcad.Database.ReadDwgFile(baseLocalFilePath, FileOpenMode.OpenForReadAndReadShare, false, "");
}
catch (System.Exception e)
{
Logging.AddLog($"Failed to read kB Template file into the drawing database:\n {e}", "error");
return;
}
}
return;
}
catch (System.Exception e)
{
Logging.AddLog($"Error loading kb base template.", "error");
return;
}
}
Solved! Go to Solution.