<?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: First line program in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146325#M31000</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The AutoCAD .NET API is designed to run in-process only.&lt;/P&gt;
&lt;P&gt;If your project is a standalone executable (e.g. a Windows Form based project) you cannot directly use the AutoCAD .NET API.&lt;/P&gt;
&lt;P&gt;See &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B" target="_blank"&gt;&lt;STRONG&gt;this topic&lt;/STRONG&gt;&lt;/A&gt; in the Developer's Guide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create an AutoCAD custom command as your example, you have to build a DLL (starting from a Class Library template) and load it in AutoCAD (the class containing the command have to be public).&lt;/P&gt;
&lt;P&gt;See &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-BA686431-C8BF-49F2-946E-9CEB2F7AE4FA" target="_blank"&gt;&lt;STRONG&gt;this section&lt;/STRONG&gt;&lt;/A&gt; in the Developer's Guide.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jun 2017 16:29:32 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2017-06-12T16:29:32Z</dc:date>
    <item>
      <title>First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146245#M30998</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a basic program using the code given on the AutoCAD developers guide.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created a class and then called the class with a button in a c# windows form. The code is for the class is below. The line "Document acDoc = Application.DocumentManager.MdiActiveDocument;" causes the program to stop? Any ideas? The button calls class DrawLine.AddLine&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using System;&lt;BR /&gt;using System.Collections.Generic;&lt;BR /&gt;using System.Linq;&lt;BR /&gt;using System.Text;&lt;BR /&gt;using System.Threading.Tasks;&lt;BR /&gt;using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;using Autodesk.AutoCAD.ApplicationServices;&lt;BR /&gt;using Autodesk.AutoCAD.DatabaseServices;&lt;BR /&gt;using Autodesk.AutoCAD.Geometry;&lt;BR /&gt;&lt;BR /&gt;namespace AutoCAD_Line_Test&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class DrawLine&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [CommandMethod("AddLine")]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void AddLine()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get the current document and database&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document acDoc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Database acCurDb = acDoc.Database;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Start a transaction&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Open the Block table for read&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BlockTable acBlkTbl;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OpenMode.ForRead) as BlockTable;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Open the Block table record Model space for write&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BlockTableRecord acBlkTblRec;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OpenMode.ForWrite) as BlockTableRecord;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create a line that starts at 5,5 and ends at 12,3&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Line acLine = new Line(new Point3d(5, 5, 0),&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new Point3d(12, 3, 0));&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acLine.SetDatabaseDefaults();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add the new object to the block table record and the transaction&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acBlkTblRec.AppendEntity(acLine);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acTrans.AddNewlyCreatedDBObject(acLine, true);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Save the new object to the database&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acTrans.Commit();&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 16:04:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146245#M30998</guid>
      <dc:creator>pedcarson</dc:creator>
      <dc:date>2017-06-12T16:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146315#M30999</link>
      <description>&lt;P&gt;Well, since you know the code stops at the first line,&amp;nbsp;all lines of the code after that are irrelevant, and the relevant code that might be the real cause of the issue is the caller: the windows form, which you did not show, nor describe how/where it runs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this win form in another DLL file that also runs as AutoCAD Add-in (NETLOADED into AutoCAD)? or it is part of stand-alone app (EXE)? If it is later, then from the EXE, you CANNOT use DLLs built with AutoCAD .NET API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Describe what kind of project you are doing,&amp;nbsp;and from where the win form&amp;nbsp;runs.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 16:25:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146315#M30999</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2017-06-12T16:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146325#M31000</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The AutoCAD .NET API is designed to run in-process only.&lt;/P&gt;
&lt;P&gt;If your project is a standalone executable (e.g. a Windows Form based project) you cannot directly use the AutoCAD .NET API.&lt;/P&gt;
&lt;P&gt;See &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B" target="_blank"&gt;&lt;STRONG&gt;this topic&lt;/STRONG&gt;&lt;/A&gt; in the Developer's Guide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create an AutoCAD custom command as your example, you have to build a DLL (starting from a Class Library template) and load it in AutoCAD (the class containing the command have to be public).&lt;/P&gt;
&lt;P&gt;See &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-BA686431-C8BF-49F2-946E-9CEB2F7AE4FA" target="_blank"&gt;&lt;STRONG&gt;this section&lt;/STRONG&gt;&lt;/A&gt; in the Developer's Guide.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 16:29:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146325#M31000</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-06-12T16:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146643#M31001</link>
      <description>I wasn't aware of netloading. I assumed I could run an exe. My aim is to&lt;BR /&gt;have a windows form program with different values to fit in which would&lt;BR /&gt;then draw certain shapes, eventually import a block and then scale it etc.&lt;BR /&gt;All from a couple of inputs from the user.&lt;BR /&gt;&lt;BR /&gt;This is obviously my first program I'm writing in c# for autocad. I don't&lt;BR /&gt;see much in tutorials for c# on the internet.&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jun 2017 18:10:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146643#M31001</guid>
      <dc:creator>pedcarson</dc:creator>
      <dc:date>2017-06-12T18:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146780#M31002</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3881196"&gt;@pedcarson&lt;/a&gt; wrote:&lt;BR /&gt;I wasn't aware of netloading. I assumed I could run an exe. &lt;BR /&gt;......&lt;BR /&gt;I'm writing in c# for autocad. I don't&lt;BR /&gt;see much in tutorials for c# on the internet.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since you seems emphasizing C#, and not aware of&amp;nbsp;"NETLOAD":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using C#, or other .NET language (VB.NET, F#...) does not matter here. What matters is which AutoCAD API to use: if you use AutoCAD .NET API, as your code showed in your original post, you CANNOT use them in EXE application, you would need redesign/restructure of your solution: app runs inside AutoCAD (as DLL), or app run outside AutoCAD (exe, which in turn automate AutoCAD in someway), based on the APIs you use (.NET API, or COM API, or both mixed).&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 19:05:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7146780#M31002</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2017-06-12T19:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7147340#M31003</link>
      <description>&lt;P&gt;Hi OP&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my estimable colleagues&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;have said it all and anything they write is very good. but i'm not sure if you understand what they are saying given your comments. so i thought to simplify it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;in process&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;this means that the user has to &lt;STRONG&gt;&lt;EM&gt;first&lt;/EM&gt;&lt;/STRONG&gt; open autocad. i.e. double click on the AutoCAD icon and start up autocad. once autocad is open and a drawing is opened, then the user has to type in a command: "NETLOAD" and has to select the a file - the result of all your programming/coding efforts. once that file is selected the user then has to run the command "&lt;SPAN&gt;AddLine". the command will run as you have coded it. in order to do it this way you will need the &lt;EM&gt;.Autocad net API&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;out of process&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In this case, you don't necessarily have to manually open AutoCAD up. you create your own program, and you open it (much like you would open MS word etc) and your "AddLine" command would run without you, as a user, manually opening autocad and netloadin etc.. if you're going down this path you need to use the &lt;EM&gt;COM interop API&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;using both&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;if you really want to use the .net API, but did not want to manually netload, then&amp;nbsp;you can use a combination of both of the above:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the documentation:&lt;/P&gt;
&lt;P class="p"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;gt;&amp;nbsp;&lt;/STRONG&gt;If you need to create a stand-alone application to drive AutoCAD, it is best to create an application that uses the &lt;SAMP id="GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B__GUID-0AA58504-56BD-4722-A8DA-F60676C41EBD" class="ph codeph"&gt;CreateObject&lt;/SAMP&gt; and &lt;SAMP id="GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B__GUID-9D05D855-EBDC-4BFA-B909-EDE66D9D0F46" class="ph codeph"&gt;GetObject&lt;/SAMP&gt; methods to create a new instance of an AutoCAD application or return one of the instances that is currently running. Once a reference to an &lt;SAMP id="GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B__GUID-1C6E507B-888D-49D0-8E5F-8BF328C7C54D" class="ph codeph"&gt;AcadApplication&lt;/SAMP&gt; is returned, you can then load your in-process .NET application into AutoCAD by using the &lt;SAMP id="GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B__GUID-B76E5514-128C-46DF-83F4-A5830846F37E" class="ph codeph"&gt;SendCommand&lt;/SAMP&gt; method that is a member of the &lt;SAMP id="GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B__GUID-0DA8DC73-07C0-434D-948A-9AC7B5B94B82" class="ph codeph"&gt;ActiveDocument&lt;/SAMP&gt; property of the &lt;SAMP id="GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B__GUID-0286B822-ACD3-4E9F-A9B5-884FCD6595C3" class="ph codeph"&gt;AcadApplication&lt;/SAMP&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p"&gt;&amp;gt; As an alternative to executing your .NET application in-process, could use COM interop for your application.&lt;/P&gt;
&lt;P class="p"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p"&gt;hope this clears it &amp;nbsp;up.&lt;/P&gt;
&lt;P class="p"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 00:45:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7147340#M31003</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-06-13T00:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7147825#M31004</link>
      <description>Thanks for such a detailed response. I would prefer to use an external&lt;BR /&gt;program but I think the main objective is to have variables at the&lt;BR /&gt;beginning that are defined by the user. So instead of just typing add line&lt;BR /&gt;and having x and y coordinates, I could have x and y set to variables that&lt;BR /&gt;are set at the start through a form. Then when addline is executed, the&lt;BR /&gt;line changes according to the variables.&lt;BR /&gt;&lt;BR /&gt;Similarly I was hoping to have a block inserted and scaled. I'd rather get&lt;BR /&gt;away from typing commands and have a user interface that anyone could use?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jun 2017 07:52:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7147825#M31004</guid>
      <dc:creator>pedcarson</dc:creator>
      <dc:date>2017-06-13T07:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7148812#M31005</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use a standalone Windows Form executable, you have to keep mind you have to use the COM API which is less powerfull than the .NET one and which have compatibility issues with platform (32 or 64 bits) and with AutoCAD major versions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a trivial example using a very simple Windows Form:&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-center" image-alt="DrawLine.png" style="width: 242px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/366638iAF4B76B8408DBEF9/image-size/large?v=v2&amp;amp;px=999" role="button" title="DrawLine.png" alt="DrawLine.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The Form Class code (Autodesk.AutoCAD.Interop and Autodesk.AutoCAD.Interop.Common libraries corresponding to targetted version of AutoCAD have to be referenced).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WinFormStandAlone
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            btnOK.Click += BtnOK_Click;
        }

        private void BtnOK_Click(object sender, EventArgs e)
        { 
            double[] startPoint, endPoint;
            if (!TryParseToPoint(txtStartPoint.Text, out startPoint))
                MessageBox.Show($"Invalid Start point.");
            if (!TryParseToPoint(txtEndPoint.Text, out endPoint))
                MessageBox.Show($"Invalid End point.");

            AcadApplication acadApp;
            string progId = "AutoCAD.Application.19";
            try
            {
                acadApp = (AcadApplication)Marshal.GetActiveObject(progId);
            }
            catch
            {
                try
                {
                    acadApp = (AcadApplication)Activator.CreateInstance(Type.GetTypeFromProgID(progId), true);
                }
                catch
                {
                    MessageBox.Show("Instance of 'AutoCAD.Application' could not be created.");
                    return;
                }
            }
            while (true)
            {
                try { acadApp.Visible = true; break; }
                catch { }
            }
            acadApp.WindowState = AcWindowState.acMax;
            AcadDocument doc = acadApp.ActiveDocument;
            AcadModelSpace modelSpace = doc.ModelSpace;
            modelSpace.AddLine(startPoint, endPoint);
        }

        private static bool TryParseToPoint(string source, out double[] point)
        {
            point = null;
            string[] array = source.Split(',');
            if (array.Length &amp;lt; 2 || array.Length &amp;gt; 3)
                return false;
            double x, y, z = 0.0;
            if (!double.TryParse(array[0], out x))
                return false;
            if (!double.TryParse(array[1], out y))
                return false;
            if (array.Length == 3 &amp;amp;&amp;amp; !double.TryParse(array[2], out z))
                return false;
            point = new[] { x, y, z };
            return true;
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the AutoCAD .NET API, you can also have a user interface as modal dialog (the dialog form have the same controls as upper):&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-center" image-alt="Dialog.png" style="width: 194px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/366684iAA55BAB4BA5D9C46/image-size/large?v=v2&amp;amp;px=999" role="button" title="Dialog.png" alt="Dialog.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System.Windows.Forms;

namespace InProcessDialog
{
    public partial class Dialog : Form
    {
        public string StartPoint =&amp;gt; txtStartPoint.Text;

        public string EndPoint =&amp;gt; txtEndPoint.Text;

        public Dialog()
        {
            InitializeComponent();
            btnOK.DialogResult = DialogResult.OK;
        }
    }
}&lt;/PRE&gt;
&lt;P&gt;The dialog is opened from AutoCAD with the "DRAWLINEDLG" command:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System.Windows.Forms;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace InProcessDialog
{
    public class Commands
    {
        [CommandMethod("DrawLineDlg")]
        public void DrawLine()
        {
            var dlg = new Dialog();
            if (AcAp.ShowModalDialog(dlg) == DialogResult.OK)
            {
                Point3d startPoint, endPoint;
                if (!TryParseToPoint(dlg.StartPoint, out startPoint))
                {
                    MessageBox.Show($"Invalid Start point.");
                    return;
                }
                if (!TryParseToPoint(dlg.EndPoint, out endPoint))
                {
                    MessageBox.Show($"Invalid End point.");
                    return;
                }

                var doc = AcAp.DocumentManager.MdiActiveDocument;
                var db = doc.Database;
                var ed = doc.Editor;
                using (var tr = db.TransactionManager.StartTransaction())
                {
                    BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(
                        SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                    Line line = new Line(startPoint, endPoint);
                    modelSpace.AppendEntity(line);
                    tr.AddNewlyCreatedDBObject(line, true);
                    tr.Commit();
                }
            }
        }

        private static bool TryParseToPoint(string source, out Point3d point)
        {
            point = default(Point3d);
            string[] array = source.Split(',');
            if (array.Length &amp;lt; 2 || array.Length &amp;gt; 3)
                return false;
            double x, y, z = 0.0;
            if (!double.TryParse(array[0], out x))
                return false;
            if (!double.TryParse(array[1], out y))
                return false;
            if (array.Length == 3 &amp;amp;&amp;amp; !double.TryParse(array[2], out z))
                return false;
            point = new Point3d(x, y, z);
            return true;
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;You can also use a modeless user interface from AutoCAD (typically a palette set)&lt;/P&gt;
&lt;P&gt;The user control (a palette tab of the palette set) contains the same controls as the upper forms.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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-center" image-alt="Palette.png" style="width: 234px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/366681iE0BE35ED208C6874/image-size/large?v=v2&amp;amp;px=999" role="button" title="Palette.png" alt="Palette.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With modeless user interfaces, it's simpler and safer to call cusom commands from event handlersso that AutoCAD takes care of locking the document and setting the focus to AutoCAD window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System;
using System.Windows.Forms;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace InProcessPalette
{
    public partial class DrawLineTab : UserControl
    {
        public DrawLineTab()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!IsValidPoint(txtStartPoint.Text))
            {
                MessageBox.Show("Invalid Start Point.");
                return;
            }
            if (!IsValidPoint(txtEndPoint.Text))
            {
                MessageBox.Show("Invalid End Point.");
                return;
            }
            var doc = AcAp.DocumentManager.MdiActiveDocument;
            doc?.SendStringToExecute($"DrawLineCmd {txtStartPoint.Text} {txtEndPoint.Text} ", false, false, false);
        }

        private bool IsValidPoint(string source)
        {
            string[] array = source.Split(',');
            if (array.Length &amp;lt; 2 || array.Length &amp;gt; 3)
                return false;
            double x;
            if (!double.TryParse(array[0], out x))
                return false;
            if (!double.TryParse(array[1], out x))
                return false;
            if (array.Length == 3 &amp;amp;&amp;amp; !double.TryParse(array[2], out x))
                return false;
            return true;
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;The palette is showned by running the "CMD_PALETTE" command, and a click on the OK button launches the "DrawLineCmd" which can also be directly called.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.Windows;

namespace InProcessPalette
{
    public class Commands
    {
        static PaletteSet palette;
        static bool wasVisible;

        [CommandMethod("CMD_PALETTE")]
        public void CmdPalette()
        {
            if (palette == null)
            {
                palette = new PaletteSet(
                    "Palette",
                    "CMD_PALETTE",
                    new Guid("{4E63230E-EEB0-45FF-A9A1-65D4FDEAE5DC}"));
                palette.Style =
                    PaletteSetStyles.ShowAutoHideButton |
                    PaletteSetStyles.ShowCloseButton |
                    PaletteSetStyles.ShowPropertiesMenu;
                palette.MinimumSize = new System.Drawing.Size(250, 150);
                palette.Add("Draw Line", new DrawLineTab());

                var docs = AcAp.DocumentManager;
                docs.DocumentBecameCurrent += (s, e) =&amp;gt;
                    palette.Visible = e.Document == null ? false : wasVisible;
                docs.DocumentCreated += (s, e) =&amp;gt;
                    palette.Visible = wasVisible;
                docs.DocumentToBeDeactivated += (s, e) =&amp;gt;
                    wasVisible = palette.Visible;
                docs.DocumentToBeDestroyed += (s, e) =&amp;gt;
                {
                    wasVisible = palette.Visible;
                    if (docs.Count == 1)
                        palette.Visible = false;
                };
            }
            palette.Visible = true;
        }

        [CommandMethod("DrawLineCmd")]
        public void DrawLine()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var options = new PromptPointOptions("\nStart Point: ");
            var result = ed.GetPoint(options);
            if (result.Status != PromptStatus.OK)
                return;
            var startPoint = result.Value;

            options.BasePoint = startPoint;
            options.UseBasePoint = true;
            options.Message = "\nend Point: ";
            result = ed.GetPoint(options);
            if (result.Status != PromptStatus.OK)
                return;
            var ucs = ed.CurrentUserCoordinateSystem;
            var endPoint = result.Value.TransformBy(ucs);
            startPoint = startPoint.TransformBy(ucs);

            using (var tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(
                    SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                Line line = new Line(startPoint, endPoint);
                modelSpace.AppendEntity(line);
                tr.AddNewlyCreatedDBObject(line, true);
                tr.Commit();
            }
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 14:08:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7148812#M31005</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-06-13T14:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7150414#M31006</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;has kindly noted in his post - and also very kindly provided sample code too: you can certainly have forms in your plugin - if you're doing that then I recommend you do things &lt;EM&gt;&lt;STRONG&gt;in process - &amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;use the powerful .net API.&amp;nbsp;just type in "AddLine" and the form will come up. Refer to Gilles' post.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:17:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7150414#M31006</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-06-13T23:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: First line program</title>
      <link>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7151416#M31007</link>
      <description>&lt;P&gt;Thank you for the detailed response, this will certainly help with understanding how to put all this together!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 10:46:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/first-line-program/m-p/7151416#M31007</guid>
      <dc:creator>pedcarson</dc:creator>
      <dc:date>2017-06-14T10:46:06Z</dc:date>
    </item>
  </channel>
</rss>

