PDA

View Full Version : Utilizing SHELL OS command?



StykFacE
16th Jan 2012, 04:42 pm
I'm wanting to know if I can open a program (or any file rather) directly from AutoCAD? What I'm trying to accomplish is this:

We are building a library of Tool Palettes that are "client specific" with use of Profiles in AutoCAD. At the top of each group of Tool Palettes we want an "Info" tab. From there, they can click an icon that will bring up the PDF document of the standards we receive from the client, so that if there's any confusion the drafter can always rely on the Info Tab of the Tool Palettes. We'll also want to link to other things, such as Word documents, maybe a job directory, Excel files with certain job schedules, etc.

Can this be done with ease? I've been trying to type into the Command Line path directories after initiating the SHELL command but I'm coming up way empty handed.

Thanks in advance. 8)

alanjt
16th Jan 2012, 05:03 pm
You can you wscript, but the easiest way would be to utilize the start command.
eg.


Command: start

Application to start: c:\\300.pdf

code:

(command "_.start" "c:\\300.pdf")

StykFacE
16th Jan 2012, 05:08 pm
Perfect!! Works great. I guess there can't be any spaces in the file name? I had to replace space with an underscore. Soon as I did that, things started opening correctly. Exactly what I need, thanks yet again for your pimpin' skillz Alan.

alanjt
16th Jan 2012, 05:58 pm
From what I remember, spaces will work if calling directly from TP if put them in a command set (command "_.shell" ...") instead of treating it like a macro.

alanjt
16th Jan 2012, 06:00 pm
Here's a wscript example, but I don't really see it being needed...


(defun AT:OpenFile (file / s r)
;; Open specified file
;; file - file to open
;; Alan J. Thompson, 11.16.10
(if (setq file (findfile file))
(progn (setq r (vl-catch-all-apply
(function
(lambda (/)
(vlax-invoke (setq s (vlax-create-object "Shell.Application")) 'Open file)
)
)
)
)
(vlax-release-object s)
(not (vl-catch-all-error-p r))
)
)
)

StykFacE
16th Jan 2012, 06:02 pm
Actually I tried to put the command set directly in the Command String text area in the Tool Palette directly, and it failed with this error:
Command: (command "_.start" "C:So then I made a quick routine and it works from the Tool Palette if I just call the function:

(defun C:TEST (/)
(command "_.start"
"C:\\Autodesk\\TDP_CADD_Standards_Manual.pdf"
)
)But I can live with that. That's what spawned my other post in the LISP section about combining multiple commands into one file.

StykFacE
16th Jan 2012, 06:03 pm
Here's a wscript example, but I don't really see it being needed...


(defun AT:OpenFile (file / s r)
;; Open specified file
;; file - file to open
;; Alan J. Thompson, 11.16.10
(if (setq file (findfile file))
(progn (setq r (vl-catch-all-apply
(function
(lambda (/)
(vlax-invoke (setq s (vlax-create-object "Shell.Application")) 'Open file)
)
)
)
)
(vlax-release-object s)
(not (vl-catch-all-error-p r))
)
)
)
Oh crap, that's way above me! :oops: