OPEN PDF FILE FROM AUTOCAD MENU

Discussion in 'AutoCAD' started by connie, Mar 25, 2005.

  1. connie

    connie Guest

    [&STD]
    [->HELP FILES]
    ID_STD1_0 [STD1]^C^C^P(load "STD") STD
    ID_STD2_0 [STD2]^C^C_browser
    "file://H:/CEG_DESIGN_CENTER/2Cad_Support/Support/cad_std.pdf"

    hi,
    I have done about 3 to 4 days worth of research on how to open a PDF file
    from an AutoCAD menu. I have been successful on the two solutions I have
    found, however....the first STD1 menu leaves the shell window open and it
    closes after I close the PDF file, I would prefer for the shell window to
    close right of way while the PDF file its still open. on STD1 im using a
    lisp that is calling for a script file.
    (defun c:STD()
    (setvar "expert" 3)

    ;get arch code
    (setq sc (getvar "useri1"))

    ;default CEG

    (if (= sc 0) (command "script" "STD"))



    (princ)
    )

    scipt.
    Shell
    H:\CEG_DESIGN_CENTER\2Cad_Support\Support\CAD_STD.PDF

    STD2 works once in while, it locks up the pc for about 5 minutes, would
    prefer to call the PDF file from adobe not from the browser.
    I don't know lisp. I do know how to modify existing lisp.

    any help, corrections, suggestions will be greatly appreciated.

    Thanks in advance
    Connie
     
    connie, Mar 25, 2005
    #1
  2. connie

    ECCAD Guest

    You could try this, found by searching for 'startapp'.

    ----------------------------
    From the help file:

    (startapp appcmd [file])

    appcmd

    A string that specifies the application to execute. If appcmd does not
    include a full path name, startapp searches the directories in the PATH
    environment variable for the application.

    file

    A string that specifies the file name to be opened.


    So you need to either edit your PATH environment variable for Windows or
    specify the entire path for acrord32.exe.

    HTH
     
    ECCAD, Mar 25, 2005
    #2
  3. try out these handy dandy routines, they are slicker than running everything through explorer...

    (DEFUN IEXPLORE (FILENAME / )
    (IF (SETQ FILENAME (FINDFILE FILENAME))
    (startapp "C:/Program Files/Internet Explorer/IEXPLORE.EXE" FILENAME)
    )
    )

    ;(WINRUN "Dir Structure.doc")

    (DEFUN WINRUN (NAME / )
    (IF (NOT (SETQ FILENAME (FINDFILE NAME)))
    (PROGN
    (ALERT (STRCAT "File " NAME " cannot be found."))
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    (IF (NOT (FINDFILE (STRCAT (GETENV "SYSTEMROOT") "\\EXPLORER.EXE")))
    (PROGN
    (ALERT (STRCAT "Explorer cannot be found so file cannot be run."))
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    (vl-arx-import 'Startapp)
    (STARTAPP (STRCAT (GETENV "SYSTEMROOT") "\\EXPLORER.EXE") FILENAME)
    (PRINC)
    )

    ;(SHELLRUN "H&A_Irvine.chm")

    (DEFUN SHELLRUN (NAME / )
    (IF (NOT (SETQ FILENAME (FINDFILE NAME)))
    (PROGN
    (ALERT (STRCAT "File " NAME " cannot be found."))
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    (IF (NOT (FINDFILE "SHELLRUN.EXE"))
    (PROGN
    (ALERT (STRCAT "SHELLRUN.EXE cannot be found so file cannot be run."))
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    (vl-arx-import 'Startapp)
    (STARTAPP (STRCAT (FINDFILE "SHELLRUN.EXE") " " FILENAME))
    (PRINC)
    )

    ;(CT-RUNPDF "C:\\CAD_SUPPORT\\A2002\\Help Documents\\Full Weight BW.pdf")

    (DEFUN RUNPDF (NAME / )
    ;TRY TO GET LOCATION OF PROGRAM
    (IF (NOT (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\Acrobat Settings\\" "AcrobatEXE"))
    (IF (AND (SETQ PDFREG (vl-registry-read "HKEY_CLASSES_ROOT\\AcroExch.Document\\shell\\Open\\command"))
    (SETQ END (vl-string-search ".EXE" (STRCASE PDFREG)))
    )
    (PROGN
    ;GET ACTUAL EXE
    (SETQ STRING (SUBSTR PDFREG 1 (+ END 4))
    DONE 0
    INDEX 1
    )
    (WHILE (AND (= DONE 0)
    (< INDEX (STRLEN STRING))
    )
    (IF (WCMATCH (SUBSTR STRING INDEX 1) "@")
    (SETQ DONE 1
    START INDEX
    )
    )
    (SETQ INDEX (+ 1 INDEX))
    )
    (SETQ EXE (SUBSTR STRING START))
    ;SAVE TO REGISTRY
    (IF (AND EXE (WCMATCH (STRCASE EXE) "*.EXE"))
    (REG-WRITE "Acrobat Settings\\" "AcrobatEXE" EXE)
    )
    )
    ;ELSE GET FROM USER
    (PROGN
    (ALERT "Could not find Acrobat Reader, please Browse for the program")
    (SETQ EXE (GETFILED "Select Acrobat Reader EXE" "C:\\PROGRAM FILES\\" "exe" 32))
    (IF (NOT EXE)
    (VL-EXIT-WITH-VALUE 1)
    )
    ;SAVE TO REGISTRY
    (IF (AND EXE (WCMATCH (STRCASE EXE) "*.EXE"))
    (REG-WRITE "Acrobat Settings\\" "AcrobatEXE" EXE)
    )
    )
    )
    ;ELSE USE REG ONE
    (SETQ EXE (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\Acrobat Settings\\" "AcrobatEXE"))
    )
    ;FIND PDF
    (IF (NOT (SETQ FILENAME (FINDFILE NAME)))
    (PROGN
    (ALERT (STRCAT "File " NAME " cannot be found."))
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    ;RUN WITH ACROBAT
    (IF (NOT (FINDFILE EXE))
    (PROGN
    (ALERT "Acrobat cannot be found so file cannot be run.")
    (VL-EXIT-WITH-VALUE 1)
    )
    )
    (STARTAPP EXE FILENAME)
    (PRINC)
    )


    the shellrun exe is attached, it gets around problems with opening chm's (help files)



    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Mar 26, 2005
    #3
  4. connie

    connie Guest

    hi,
    I did tried your recommendation but it too complicated for me.
    however you responded to an AUTOCAD MENU FILE post; I tried what you and
    Walt Engle suggested and it did exactly what i wanted it to do..

    this is my end result. it works like a charm because I am not specifying
    which adobe reader to launch.
    ***POP1
    [&STD]
    [->HELP FILES]
    ID_STANDARDS_0 [STANDARDS](command "_start"
    "H://DESIGN_CENTER/2Cad_Support/Support/CAD_STD.PDF")

    Thanks again,
    Connie
     
    connie, Mar 29, 2005
    #4
  5. connie

    connie Guest

    Thank you for providing your code. I didn't get it too work. I'm sure I had
    to modify the code to fit my need. I don't enough lisp, but I did tried to
    program it.

    Thanks again,

    Connie
     
    connie, Mar 29, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.