Jump to content

Recommended Posts

Posted

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)

Posted

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")

Posted

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.

Posted

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.

Posted

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))
   )
 )
)

Posted

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.

Posted
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:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...