How to open file by AutoCAD commandline

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I am trying to import a PDF using just the AutoCAD command line. I want to automate this process for purpose of a much bigger project. My code is below:
public static void SendACommandToAutoCAD(string userfile)
{
string command;
Document acDoc = Application.DocumentManager.MdiActiveDocument;
command = "._-PDFIMPORT f " + "'" + userfile + "'" + " 1 0,0 1.0 0";
acDoc.SendStringToExecute(command, true, false, false);
}
In order, ._-PDFIMPORT is the command, f is file or underlay, userfile is user's input of filepath, 1 is page number, 0,0 is position, 1.0 is scale factor, 0 is rotation. The only thing that changes for the purpose of this is userfile.
Please help me figure out why the command is not working. When I put it, it gets stuck at the dialog box to select the file and does not open the file. How do I get passed this dialog box?
If my code is bad please let me know any adjustments you would recommend.
Thank you so much!