Can you open AutoCAD from another exe?

I want to open AutoCAD from another exe. First I want to open a drawing file with a name that I pass to AutoCAD.

Secondly I want to be able to open an existing drawing file with a name that I pass to AutoCAD.

How would I do this? I have no experience of AutoCAD – my customer wants to be able to this.

Thanks

Asked on November 16, 2016 in AutoCAD.
Add Comment
10 Answer(s)

Hi there rbarton,

You can run the program using the shell command with the following Command Line parameter switch.

/b

 

Script name

 

Designates a script to run after you start the program (b stands for batch process).

 

If the script file is in the Start In folder, a full path to the script file is required unless this security measure is suppressed either by including the /six command line switch, or setting the LEGACYCODESEARCH system variable to 1.

 

Scripts can be used to set up drawing parameters in a new drawing file. An SCR file type is assumed.

 

“C:\Program Files\Autodesk\AutoCAD 2015\acad.exe” /product ACAD /language “en-US” /b startup

where “startup” is the script name.

You can go ahead and create the script using the OPEN command
First Case you can put the OPEN command with the filename

Second Case you can put the OPEN command without the filename and AutoCAD will automatically ask for the filename to open

For full reference of Command line switches please visit: http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-8E54B6EC-5B52-4F62-B7FC-0D4E1EDF093A

For full reference of scripting please visit: https://cadanswers.com/question/how-do-you-create-an-autocad-script/

Hope this helps 🙂

Answered on November 16, 2016.
Add Comment

Hi again rbarton,

Hope everything is fine. An AutoCAD script file is basically a text file which contains anything you would write in the command line interface inside AutoCAD

A good example can be found here :

http://www.cad-notes.com/learn-how-to-write-command-scripts-for-autocad-and-automate-your-plotting/

Answered on November 23, 2016.
Add Comment

Hi there rbarton,

the /b option does not open a .dwg file but instead opens an AutoCAD script file inside of which you can write your script which would basically be “OPEN <.dwg file directory>” or just “OPEN”.

Answered on November 20, 2016.
Add Comment

My control program chooses a dwg file name – then it wants to shell out to autocad and open the passed file name – a dwg file. The user then does the drawing – saves the file and closes autocad – then control is passed back.

In the second setup, my program will supply the dwg name but this time open autocad to edit the passed file name. The user then edits the drawing – saves the file and closes autocad – then control is passed back.

Thanks for your reply. Hope this reply makes sense!

 

Answered on November 16, 2016.
Add Comment

So far so good! I have an exe which opens autocad. This works as expected.

BUT I am unable to open a file etc. The problem is that I do not understand how to create a script file. The /b option when I use fails to open a file. The original exe works as expected using other command line options from other software – eg. i can open pdf files  using adobe acrobat from the commad line so I think my code is correct!

It’s just that Autocad doesn’t like my code.

For instance if I want to open a file named DR1527.dwg – what code do I need in the script file? As I understand script files – they are text files that can be created using notepad? The file resides in a folder named  CADFiles.

Thanks

 

Answered on November 20, 2016.
Add Comment

Looks good to me – I will set up a test exe to utilise your answer. Should be good!

Thanks

 

Answered on November 16, 2016.
Add Comment

No – I understand the ‘b’ option opens a script file.

What I do not understand is what needs to go into the script file – if I wanted to do as previously stated what do I need in the script file?

Where would the script file be stored? Is there a preferred place?

Thanks

Answered on November 21, 2016.
Add Comment

Hi rbarton,

To help me better understand the issue can I please ask:

  1. Do you want to open another extension file as a drawing?
  2. Or Do you intend to open another exe for security reason which in turn would run AutoCAD?

Step 1:

To use the Command Window Set FILEDIA to 0 (zero) (OPEN displays the Command prompt open options.)

To use the Normal Window Set FILEDIA to 1 (One) (The Select File dialog box (a standard file selection dialog box) is displayed.)

Step 2:

Type OPEN [FileName]

Step 3:

For other file types please use the IMPORT command

 

Hope this helps.

Answered on November 16, 2016.
Add Comment

Great, Tell us how it goes 🙂

Answered on November 17, 2016.
Add Comment

There are several methods how to launch an external .EXE application from the AutoCAD environment.

The easiest way (similarly also in AutoCAD LT) is the function (startapp) – you can e.g. run NotePad by entering (startapp "notepad.exe").

Another method are the commands SHSHELL and START, which can be used to invoke and external OS command or program.

Another often used method is adding the requested .EXE application to the ACAD.PGP file – creating an command (program) alias. See the PBRUSHcommand alias definiton as a sample.

AutoCAD offers many other ways to start a program – e.g. the Shell function in VBAARX programming environment, MTEXTED setting, etc.

Answered on February 6, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.