Open PDF (or other filetypes) from AutoCAD

Open PDF (or other filetypes) from AutoCAD

toolbox2
Advocate Advocate
4,307 Views
7 Replies
Message 1 of 8

Open PDF (or other filetypes) from AutoCAD

toolbox2
Advocate
Advocate

I want to define some buttons that will open certain reference documents - usually PDFs.

The following command works fine when entered directly on the Command line but not when added as a macro to a button.

 

(startapp "explorer c:\\temp\\file.pdf")

 

I've tried burying the command within a Lisp function. Didn't work.

 

I've Googled for answers and have got close but still not quite there. Something to do with the backslashes being interpreted as a pause.

 

Any ideas?

0 Likes
Accepted solutions (1)
4,308 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

Probably just wrong quite marks.

 

(startapp "explorer" "c:\\temp\\file.pdf")

0 Likes
Message 3 of 8

toolbox2
Advocate
Advocate

@ВeekeeCZ wrote:

Probably just wrong quite marks.

 

(startapp "explorer" "c:\\temp\\file.pdf")


Fraid not. That works on the command line but not when defined as a macro in a button.

The command pauses here :

 

(startapp "explorer c:

 

The backslashes are causing it to pause.

I've tried replacing the double-backslashes with single forward slashes. The result is that Explorer then opens up on the specified folder but the PDF file doesn't open with the default PDF application.

 

Using AutoCAD Map 2016, by the way.

0 Likes
Message 4 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Not sure why... but you try THIS method.

 

0 Likes
Message 5 of 8

toolbox2
Advocate
Advocate

@ВeekeeCZ wrote:

Not sure why... but you try THIS method.

 


Brilliant! All I needed was to prefix the filepath with "file://".

So, I now have :

 

(startapp "explorer file://c:/temp/file.pdf")

 

I haven't explored the lisp in that Civil 3D post but the above solution seems to be working.

 

Many thanks.

 

 

Message 6 of 8

scot-65
Advisor
Advisor
Alternate:
(vl-load-com)
(vl-cmdf ".BROWSER" (strcat "\"" %DPATH% a "\""))
where %DPATH% is a hard-path prefix to a specific folder and
a is the full file name with extension.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 7 of 8

toolbox2
Advocate
Advocate

@scot-65 wrote:
Alternate:
(vl-load-com)
(vl-cmdf ".BROWSER" (strcat "\"" %DPATH% a "\""))
where %DPATH% is a hard-path prefix to a specific folder and
a is the full file name with extension.

???

Thanks for the input.

This code opens the file in my default browser (Chrome). It works but didn't handle MS Word docx files - Chrome just downloaded the file.

 

The startapp function works wells and opens the file with the system default application. Are there limitations with startapp?

 

Thanks again.

 

0 Likes
Message 8 of 8

scot-65
Advisor
Advisor
The snippet I provided is intended to open up file(s) that cannot be edited.
By downloading the non-browser able files (such as DOC), the downloaded
file can be edited and the original preserved.

command STARTAPP, to my knowledge, has no limitations.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes