.NET

Reply
Active Contributor
jprisbe
Posts: 37
Registered: ‎02-22-2005
Message 1 of 4 (822 Views)
Accepted Solution

Getting command-line parameters

822 Views, 3 Replies
07-11-2012 08:33 AM

From my .NET dll I need to get the command line parameters that were used when AutoCAD was launched.

 

In the unmanaged world I used acedGetAcadWinApp.

 

Is there a .NET equivalent?

 

Thanks,

 //"C:\Program Files\AutoCAD 20xx\acad.exe" /p "..\Acad.arg" /myArg1 /nologo
//Command: args
//Arg0="D:\Program Files\AutoCAD 20xx.exe"
//Arg1="/p"
//Arg2="..\Acad.arg"
//Arg3="/myArg1"
//Arg4="/nologo"
[CommandMethod("Args")]
public void GetAcadArguments()
{
Document dwg = Application.DocumentManager.MdiActiveDocument;
Editor ed = dwg.Editor;
int i = 0;
foreach (string arg in Environment.GetCommandLineArgs())
{
ed.WriteMessage("\n Arg{0}=\"{1}\"",i++,arg);
}
}

 

*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 2 of 4 (808 Views)

Re: Getting command-line parameters

07-11-2012 10:21 AM in reply to: jprisbe

Not that I am aware of.

 

It appears that acedGetAcadWinApp can be PInvoked, but I'm not sure how you would access the properties from the Pointer that is returned.

 

the signature for 32bit AutoCAD 2012 appears to be ?acedGetAcadWinApp@@YAPAVCWinApp@@XZ

Dave O.                                                                  Sig-Logos32.png
Mentor
SENL1362
Posts: 212
Registered: ‎07-20-2011
Message 3 of 4 (802 Views)

Re: Getting command-line parameters

07-11-2012 10:49 AM in reply to: chiefbraincloud
       //"C:\Program Files\AutoCAD 20xx\acad.exe" /p "..\Acad.arg"    /myArg1 /nologo
        //Command: args
        //Arg0="D:\Program Files\AutoCAD 20xx.exe"
        //Arg1="/p"
        //Arg2="..\Acad.arg"
        //Arg3="/myArg1"
        //Arg4="/nologo"
        [CommandMethod("Args")]
        	public void GetAcadArguments()
        	{
            	Document dwg = Application.DocumentManager.MdiActiveDocument;
            	Editor ed = dwg.Editor;

                int i = 0;
                foreach (string arg in Environment.GetCommandLineArgs())
                {
                    ed.WriteMessage("\n Arg{0}=\"{1}\"",i++,arg);
                }

            }

 

Active Contributor
jprisbe
Posts: 37
Registered: ‎02-22-2005
Message 4 of 4 (798 Views)

Re: Getting command-line parameters

07-11-2012 11:04 AM in reply to: jprisbe

Environment.GetCommandLineArgs() is exactly what I was looking for.

 

Thanks.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!