<?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: Newing a drawing is missing default styles in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337904#M739</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;new Database(true, true) constructor creates a new drawing with no template (as the _NEW command when choosing "Open with no template").&lt;/P&gt;
&lt;P&gt;You should use new Database(false, false) and ReadDwgFile with the path of the template you want to start with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[CommandMethod(nameof(CreateNewDrawing))]
public void CreateNewDrawing()
{
    string fileName = @"E:\Sample Project\February 2025\EmptyDrawing.dwg";
    string templateName = "SomeTemplate.dwt";
    using var db = new Database(false, false);
    db.ReadDwgFile(templateName, FileOpenMode.OpenForReadAndAllShare, false, null);
    db.SaveAs(fileName, DwgVersion.Current);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Feb 2025 08:05:55 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2025-02-25T08:05:55Z</dc:date>
    <item>
      <title>Newing a drawing is missing default styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337839#M738</link>
      <description>&lt;P&gt;Here's my code to create a new drawing from .Net code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    [CommandMethod(nameof(CreateNewDrawing))]

    public void CreateNewDrawing()
    {
        var fileName = @"E:\Sample Project\February 2025\EmptyDrawing.dwg";
        using var db = new Database(true, true);
        db.SaveAs(fileName, DwgVersion.Current);
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to stress that the correct file, EmptyDrawing.dwg is created at the designated location. But when I open it, and compare it with a new drawing I create via UI, there are critical difference, in that the (Civil 3D) styles are missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the two screenshot ( the first screenshot is for the drawing created via .Net API, the second screenshot is the drawing created via UI) that compare them:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CodeNew.png" style="width: 469px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1470672iE55DC6E5FBCAD821/image-size/large?v=v2&amp;amp;px=999" role="button" title="CodeNew.png" alt="CodeNew.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UINew.png" style="width: 473px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1470673i1A17C94F4DD299B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="UINew.png" alt="UINew.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pretty sure I don't create the drawing properly via code, any command that I miss?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 07:06:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337839#M738</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-02-25T07:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Newing a drawing is missing default styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337904#M739</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;new Database(true, true) constructor creates a new drawing with no template (as the _NEW command when choosing "Open with no template").&lt;/P&gt;
&lt;P&gt;You should use new Database(false, false) and ReadDwgFile with the path of the template you want to start with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[CommandMethod(nameof(CreateNewDrawing))]
public void CreateNewDrawing()
{
    string fileName = @"E:\Sample Project\February 2025\EmptyDrawing.dwg";
    string templateName = "SomeTemplate.dwt";
    using var db = new Database(false, false);
    db.ReadDwgFile(templateName, FileOpenMode.OpenForReadAndAllShare, false, null);
    db.SaveAs(fileName, DwgVersion.Current);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 08:05:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337904#M739</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2025-02-25T08:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Newing a drawing is missing default styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337929#M740</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;, so what's the exact command that is equivalent to the New?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess that New command is just the above coode, plus use the template file at&amp;nbsp;%localappdata%\C3D 20xx\enu\Template\_Autodesk Civil 3D (Metric) NCS.dwt, so it's just equivalent to the templateName = "%localappdata%\C3D 20xx\enu\Template\_Autodesk Civil 3D (Metric) NCS.dwt", but I don't feel like to hardcode it this way, because I don't want to change my code when I upgrade my Civil 3D version.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a upgrade proof way of reading in the template file?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 08:20:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337929#M740</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-02-25T08:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Newing a drawing is missing default styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337988#M741</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7472042"&gt;@soonhui&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;, so what's the exact command that is equivalent to the New?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you're talking about the "QNEW" command, you can get the template path with:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;string templatePath = HostApplicationServices.Current.GetEnvironmentVariable("QnewTemplate");&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Feb 2025 08:53:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13337988#M741</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2025-02-25T08:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Newing a drawing is missing default styles</title>
      <link>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13338036#M742</link>
      <description>&lt;P&gt;In the UI a template file (. dwt) is usually used as the basis for a new drawing. So you don't create a new database, instead you open a DWT file and save it as a DWG file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 09:11:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/newing-a-drawing-is-missing-default-styles/m-p/13338036#M742</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-02-25T09:11:42Z</dc:date>
    </item>
  </channel>
</rss>

