<?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 Call autocad from cmd.exe with arguments in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/call-autocad-from-cmd-exe-with-arguments/m-p/2555732#M69106</link>
    <description>Hello!&lt;BR /&gt;
I'm creating application on top of autocad. I don't know how to launch Autocad with my application and without it.&lt;BR /&gt;
I'm triing to solve this problem in next steps:&lt;BR /&gt;
- Register my dll in register, so it will automatically run with Autocad startup.&lt;BR /&gt;
- Write LISP function in acad.lsp, that will launch some function from my dll. For this I need to send some parameters into autocad on startup and I don't know how to do it? Is it possible to send parameters to Autocad from cmd.exe?&lt;BR /&gt;
&lt;BR /&gt;
Thank you for answer.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;</description>
    <pubDate>Mon, 14 Sep 2009 06:37:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-09-14T06:37:56Z</dc:date>
    <item>
      <title>Call autocad from cmd.exe with arguments</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autocad-from-cmd-exe-with-arguments/m-p/2555732#M69106</link>
      <description>Hello!&lt;BR /&gt;
I'm creating application on top of autocad. I don't know how to launch Autocad with my application and without it.&lt;BR /&gt;
I'm triing to solve this problem in next steps:&lt;BR /&gt;
- Register my dll in register, so it will automatically run with Autocad startup.&lt;BR /&gt;
- Write LISP function in acad.lsp, that will launch some function from my dll. For this I need to send some parameters into autocad on startup and I don't know how to do it? Is it possible to send parameters to Autocad from cmd.exe?&lt;BR /&gt;
&lt;BR /&gt;
Thank you for answer.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Sep 2009 06:37:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autocad-from-cmd-exe-with-arguments/m-p/2555732#M69106</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-14T06:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Call autocad from cmd.exe with arguments</title>
      <link>https://forums.autodesk.com/t5/net-forum/call-autocad-from-cmd-exe-with-arguments/m-p/2555733#M69107</link>
      <description>1.- Register my dll in register, so it will automatically run with Autocad startup.&lt;BR /&gt;
&lt;BR /&gt;
-----------------------------&lt;BR /&gt;
&lt;BR /&gt;
Simplist way is to just create a lisp file with &lt;BR /&gt;
&lt;BR /&gt;
(command "netload" "c:\\MyDll.dll")&lt;BR /&gt;
&lt;BR /&gt;
and add it to the startup Suite Contents. &lt;BR /&gt;
&lt;BR /&gt;
2. - Write LISP function in acad.lsp, that will launch some function from my dll. For this I need to send some parameters into autocad on startup and I don't know how to do it? Is it possible to send parameters to Autocad from cmd.exe?&lt;BR /&gt;
&lt;BR /&gt;
---------------------------&lt;BR /&gt;
You don't use lisp to send commands. &lt;BR /&gt;
You use the CommandMethod to define the commands&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
  *GreaterThan*CommandMethod("HelloWorld", CommandFlags.Modal)*LessThan* _&lt;BR /&gt;
  Public Sub someSubName()&lt;BR /&gt;
  end sub &lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
If you want to make a lisp Style Command, (myCommand Value1 value2), you can use;&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
    *GreaterThan*LispFunction("HelloWorld")*LessThan* _&lt;BR /&gt;
     Public Sub someSubName(ByVal rbArgs As ResultBuffer)&lt;BR /&gt;
&lt;BR /&gt;
        For Each item As Object In rbArgs&lt;BR /&gt;
            MsgBox(item.value.ToString)&lt;BR /&gt;
        Next&lt;BR /&gt;
&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
3. - Write LISP function in acad.lsp, that will launch some function from my dll. For this I need to send some parameters into autocad on startup and I don't know how to do it? Is it possible to send parameters to Autocad from cmd.exe?&lt;BR /&gt;
&lt;BR /&gt;
----------------------------&lt;BR /&gt;
If you want to send a parameter such as a filename&lt;BR /&gt;
from cmd.exe you would have to use COM.&lt;BR /&gt;
You can't use this as a dll. You would make an EXE. &lt;BR /&gt;
&lt;BR /&gt;
This is a stand alone application that takes the file names&lt;BR /&gt;
and adds them to a list on a form. &lt;BR /&gt;
You would then need to take this list and pass it to AutoCAD. &lt;BR /&gt;
Sample is Below.   &lt;BR /&gt;
&lt;BR /&gt;
I already posted a sample of how to access AutoCAD from COM here&lt;BR /&gt;
http://discussion.autodesk.com/forums/thread.jspa?messageID=6212728�&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
Namespace My&lt;BR /&gt;
&lt;BR /&gt;
    ' The following events are available for MyApplication:&lt;BR /&gt;
    ' &lt;BR /&gt;
    ' Startup: Raised when the application starts, before the startup form is created.&lt;BR /&gt;
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.&lt;BR /&gt;
    ' UnhandledException: Raised if the application encounters an unhandled exception.&lt;BR /&gt;
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. &lt;BR /&gt;
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.&lt;BR /&gt;
 &lt;BR /&gt;
    Partial Friend Class MyApplication&lt;BR /&gt;
&lt;BR /&gt;
        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup&lt;BR /&gt;
&lt;BR /&gt;
            Try&lt;BR /&gt;
                Dim strFileName As String = LongName.GetLongPathName(e.CommandLine(0))&lt;BR /&gt;
                Dim intCount = e.CommandLine.Count&lt;BR /&gt;
                AddtoList(strFileName, intCount)&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
            End Try&lt;BR /&gt;
&lt;BR /&gt;
        End Sub&lt;BR /&gt;
&lt;BR /&gt;
        Private Sub MyApplication_StartupNextInstance(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance&lt;BR /&gt;
&lt;BR /&gt;
            Try&lt;BR /&gt;
                Dim strFileName As String = LongName.GetLongPathName(e.CommandLine(0))&lt;BR /&gt;
                Dim intCount = e.CommandLine.Count&lt;BR /&gt;
                AddtoList(strFileName, intCount)&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
            End Try&lt;BR /&gt;
&lt;BR /&gt;
        End Sub&lt;BR /&gt;
&lt;BR /&gt;
        Private Sub AddtoList(ByVal strFileName As String, ByVal intCount As Integer)&lt;BR /&gt;
&lt;BR /&gt;
            If intCount &amp;gt; 0 Then&lt;BR /&gt;
                If UCase(strFileName.Substring((Len(strFileName) - 4), 4)) = UCase(".dwg") Then&lt;BR /&gt;
                    If Not isDWGDuplicate(strFileName) Then&lt;BR /&gt;
                        MyForm.lstFiles.Items.Add(strFileName)&lt;BR /&gt;
                    End If&lt;BR /&gt;
                End If&lt;BR /&gt;
            End If&lt;BR /&gt;
&lt;BR /&gt;
        End Sub&lt;BR /&gt;
&lt;BR /&gt;
    Public Function isDWGDuplicate(ByVal strValue As String) As Boolean&lt;BR /&gt;
        Dim i As Long&lt;BR /&gt;
        If MyForm.lstFiles.Items.Count &amp;gt; 0 Then&lt;BR /&gt;
            For i = 0 To MyForm.lstFiles.Items.Count - 1&lt;BR /&gt;
                If UCase(strValue) = UCase(MyProgram.lstFiles.Items(i)) Then&lt;BR /&gt;
                    Return True&lt;BR /&gt;
                    Exit For&lt;BR /&gt;
                End If&lt;BR /&gt;
            Next&lt;BR /&gt;
        End If&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
    End Class&lt;BR /&gt;
&lt;BR /&gt;
End Namespace&lt;BR /&gt;
{code}</description>
      <pubDate>Mon, 14 Sep 2009 15:30:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/call-autocad-from-cmd-exe-with-arguments/m-p/2555733#M69107</guid>
      <dc:creator>arcticad</dc:creator>
      <dc:date>2009-09-14T15:30:02Z</dc:date>
    </item>
  </channel>
</rss>

