<?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: new database, readdwgfile, insunits again in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8909840#M21842</link>
    <description>&lt;P&gt;Ok - this works.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&lt;SPAN&gt;Why do you keep on using all these useless statements (Transaction, WorkingDatabase, CloseInput)?&amp;lt;&amp;lt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;First - I didn't realise&amp;nbsp;this change could be made to the database without a transaction.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Second - the WorkingDatabase was added to make sure the change was applied to the side database (not the Drawing1 database that is open in the editor).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Third - CloseInput is used for what the documentation states.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jul 2019 15:34:41 GMT</pubDate>
    <dc:creator>fieldguy</dc:creator>
    <dc:date>2019-07-15T15:34:41Z</dc:date>
    <item>
      <title>new database, readdwgfile, insunits again</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8906786#M21839</link>
      <description>&lt;P&gt;My code is working but I get "Warning: An error occured during save. We recommend that you run Recover".&lt;/P&gt;&lt;P&gt;I'm attaching the code and an empty dwg file that is causing the issue.&amp;nbsp; I believe it was created by microstation - not sure if that makes any difference.&lt;/P&gt;&lt;P&gt;A second question: after db.SaveAs, why does autocad still tell me that "This DWG file was saved by an application that was not developed or licensed by Autodesk"?&lt;/P&gt;&lt;PRE&gt;string msg = "rename, change units";
string docpath = "\\some path\\";
string oldname = "unitstest.dwg";
string newname = "unitstest_new.dwg";
Database curdb = acdb.HostApplicationServices.WorkingDatabase;
try
{
  using (Database db = new Database(false, true))
  {
    db.ReadDwgFile(docpath + oldname, FileOpenMode.OpenForReadAndAllShare, false, "");
    db.CloseInput(true);
    HostApplicationServices.WorkingDatabase = db;
    using (Transaction tr = db.TransactionManager.StartTransaction())
    {
      db.Insunits = UnitsValue.Meters;
      tr.Commit();
    }// using tr
    db.SaveAs(docpath + newname, DwgVersion.Current);
    HostApplicationServices.WorkingDatabase = curdb;
  }// using new database           
}// try
catch (System.Exception ex)
{
  msg += "\nError:\n" + ex.Message;
}&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Jul 2019 17:50:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8906786#M21839</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2019-07-12T17:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: new database, readdwgfile, insunits again</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8907188#M21840</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you keep on using all these useless statements (Transaction, WorkingDatabase, CloseInput)?&lt;/P&gt;
&lt;P&gt;Doesn't simply do it like this work the same (or better)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;string msg = "rename, change units";
string docpath = "\\some path\\";
string oldname = "unitstest.dwg";
string newname = "unitstest_new.dwg";
try
{
  using (Database db = new Database(false, true))
  {
    db.ReadDwgFile(docpath + oldname, FileOpenMode.OpenForReadAndAllShare, false, "");
    db.Insunits = UnitsValue.Meters;
    db.SaveAs(docpath + newname, DwgVersion.Current);
  }// using new database           
}// try
catch (System.Exception ex)
{
  msg += "\nError:\n" + ex.Message;
}&lt;/PRE&gt;
&lt;P&gt;For your second question, even you save the drawing with , it does not change the fact the drawing was originaly created with another software.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 22:29:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8907188#M21840</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-07-12T22:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: new database, readdwgfile, insunits again</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8907438#M21841</link>
      <description>&lt;P&gt;If you absolutely want to change the WorkingDatabase (despite this is not mandatory to just change the insunits), try to reset the previous WorkingDatabase before calling db.SaveAs() (see &lt;A href="https://forums.autodesk.com/t5/net/new-database-readdwgfile-crashing/m-p/8898686#M63188" target="_blank" rel="noopener"&gt;this topic&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 08:29:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8907438#M21841</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-07-13T08:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: new database, readdwgfile, insunits again</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8909840#M21842</link>
      <description>&lt;P&gt;Ok - this works.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&lt;SPAN&gt;Why do you keep on using all these useless statements (Transaction, WorkingDatabase, CloseInput)?&amp;lt;&amp;lt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;First - I didn't realise&amp;nbsp;this change could be made to the database without a transaction.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Second - the WorkingDatabase was added to make sure the change was applied to the side database (not the Drawing1 database that is open in the editor).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Third - CloseInput is used for what the documentation states.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 15:34:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8909840#M21842</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2019-07-15T15:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: new database, readdwgfile, insunits again</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8909996#M21843</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/81963"&gt;@fieldguy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;First - I didn't realise&amp;nbsp;this change could be made to the database without a transaction.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I thaught you did. See your last reply in &lt;A href="https://forums.autodesk.com/t5/net/new-database-readdwgfile-insunits/m-p/8901712#M63199" target="_blank" rel="noopener"&gt;your previous topic&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/81963"&gt;@fieldguy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;Second - the WorkingDatabase was added to make sure the change was applied to the side database (not the Drawing1 database that is open in the editor).&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;While calling the Insunits property on the Database instance you just created (db.Insunits), it cannot apply to another one.&amp;nbsp; Setting the working database is only mandatory for features such as LayoutManager.Current or Entity.SetDatabaseDefaults() (if the entity is not yet added to a Database) which are implicitly related to the working database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/81963"&gt;@fieldguy&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&lt;SPAN&gt;Third - CloseInput is used for what the documentation states.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The docs aren't such clear about the CloseInput using. You should read the &lt;A href="https://help.autodesk.com/view/OARX/2019/ENU/?guid=OREF-AcDbDatabase__closeInput_bool" target="_blank" rel="noopener"&gt;ARX docs&lt;/A&gt; which says: "it may have undesirable results" and the description for the OpenForReadAndAllShare option of the &lt;A href="https://help.autodesk.com/view/OARX/2019/ENU/?guid=OREFNET-Autodesk_AutoCAD_DatabaseServices_FileOpenMode" target="_blank" rel="noopener"&gt;FileOpenMode enum&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 16:34:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-database-readdwgfile-insunits-again/m-p/8909996#M21843</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-07-15T16:34:07Z</dc:date>
    </item>
  </channel>
</rss>

