<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ReadDwgFile give eRepeatedDwgRead error on newly created drawing in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616631#M114</link>
    <description>&lt;P&gt;Are you saying that have a current drawing that is opened in AutoCAD as MdiActiveDocument and you want to: 1). keep its EXISTING contents; 2. get all contents from the download drawing file (be it template DWT file, or DWG file, it really does not matter) into the MdiActiveDocument? In the case of keeping existing contents and adding contents from other drawing file, you need to open the downloaded file as SIDE DATABASE, and then use WBlockCloneObjects() method to copy the contents into the existing opened drawing, where you would specify how to handle duplicated content (overwrite, or ignore...). You would call it many times targeting different object owners (Symbol tables, spaces...).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I am wondering why you want to do that (bring all contents from a drawing to an existing drawing). You may want to explain a bit more. However, you cannot use ReadDwgFile() with the database of an document opened in AutoCAD, that is the reason you got the said error.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 May 2025 17:38:58 GMT</pubDate>
    <dc:creator>Norman_Yuan</dc:creator>
    <dc:date>2025-05-06T17:38:58Z</dc:date>
    <item>
      <title>ReadDwgFile give eRepeatedDwgRead error on newly created drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13614946#M109</link>
      <description>&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 21:54:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13614946#M109</guid>
      <dc:creator>genelibardiDCZT4</dc:creator>
      <dc:date>2025-05-05T21:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile give eRepeatedDwgRead error on newly created drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13615162#M110</link>
      <description>&lt;P&gt;You are showing code that obtains a Database from a property of an object which you do not show. No one can tell you what the problem is without seeing all of the relevant code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to show the code that creates the Database that's used in your code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 02:54:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13615162#M110</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-05-06T02:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile give eRepeatedDwgRead error on newly created drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616390#M111</link>
      <description>&lt;P&gt;Thank you for your reply. This is a very large add-in project with a lot of code. It would be very difficult to send it all to you but I will try to include the relevant things.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For context, it is an add-in with a ribbon UI that is loaded automatically from a bundle. The end user starts AutoCAD (2024 in this case) and starts a new drawing in the normal way. Then they click&amp;nbsp;a button on the add-in ribbon panel which contacts an external web service and gets a data set that includes instructions for building a model and drawing layouts.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The database is just the one that is created when the new drawing is created and is accessed like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static Document Document
{
    get
    {
        return Application.DocumentManager.MdiActiveDocument;
    }
}

public static Database Database
{
    get
    {
        return Document.Database;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The LoadTemplate() method is executed from an "onDocOpen" method that is bound to the&amp;nbsp;Application.DocumentManager.DocumentCreated event and is the first thing done there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps clarify things.&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 15:19:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616390#M111</guid>
      <dc:creator>genelibardiDCZT4</dc:creator>
      <dc:date>2025-05-06T15:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile give eRepeatedDwgRead error on newly created drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616546#M112</link>
      <description>&lt;P&gt;You DO NOT use the MdiActiveDocument.Database to read DWG file. Since you download a drawing file and save it to the local folder, you simply call Application.DocumentManager.Add[Open]() extension method to open the template/drawing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 16:36:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616546#M112</guid>
      <dc:creator>Norman_Yuan</dc:creator>
      <dc:date>2025-05-06T16:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile give eRepeatedDwgRead error on newly created drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616609#M113</link>
      <description>&lt;P&gt;Thank you for your reply, Mr. Yuan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not downloading a dwg file that I want to open. I am downloading a template file (dwt) and I want to include everything in that file in the currently open dwg.&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 17:10:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616609#M113</guid>
      <dc:creator>genelibardiDCZT4</dc:creator>
      <dc:date>2025-05-06T17:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile give eRepeatedDwgRead error on newly created drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616631#M114</link>
      <description>&lt;P&gt;Are you saying that have a current drawing that is opened in AutoCAD as MdiActiveDocument and you want to: 1). keep its EXISTING contents; 2. get all contents from the download drawing file (be it template DWT file, or DWG file, it really does not matter) into the MdiActiveDocument? In the case of keeping existing contents and adding contents from other drawing file, you need to open the downloaded file as SIDE DATABASE, and then use WBlockCloneObjects() method to copy the contents into the existing opened drawing, where you would specify how to handle duplicated content (overwrite, or ignore...). You would call it many times targeting different object owners (Symbol tables, spaces...).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I am wondering why you want to do that (bring all contents from a drawing to an existing drawing). You may want to explain a bit more. However, you cannot use ReadDwgFile() with the database of an document opened in AutoCAD, that is the reason you got the said error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 17:38:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616631#M114</guid>
      <dc:creator>Norman_Yuan</dc:creator>
      <dc:date>2025-05-06T17:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: ReadDwgFile give eRepeatedDwgRead error on newly created drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616852#M115</link>
      <description>Thank you very much for your response. This is very helpful information.&lt;BR /&gt;Long story as to why I'm trying to do this, but in light of this&lt;BR /&gt;information, I will most likely try to find another approach. Thanks again.&lt;BR /&gt;</description>
      <pubDate>Tue, 06 May 2025 20:22:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/readdwgfile-give-erepeateddwgread-error-on-newly-created-drawing/m-p/13616852#M115</guid>
      <dc:creator>genelibardiDCZT4</dc:creator>
      <dc:date>2025-05-06T20:22:12Z</dc:date>
    </item>
  </channel>
</rss>

