Lisp for Support File Search Path

Discussion in 'AutoCAD' started by sashk, Jun 3, 2004.

  1. sashk

    sashk Guest

    Hello all, I need some help. I need a routine that can toggle some paths on my support files search path. This would occur in the plot styles search path. Can anyone help. Doing it manually, especially in a large office, can be a chore. I do not want to do this with profiles and I do not want to create shortcuts to plot styles. I just want to toggle paths without having to manually type in the new paths. Thanks. Any help would be great. I am not the greatest code write, but I understand some of it.
     
    sashk, Jun 3, 2004
    #1
  2. sashk

    sashk Guest

    Okay, I have tried doing it, but I have failed. How can I get the attached file to work. I want this routine to toggle between our network and a local machine.

    file is attached
     
    sashk, Jun 3, 2004
    #2
  3. sashk

    T.Willey Guest

    T.Willey, Jun 3, 2004
    #3
  4. sashk

    sashk Guest

    i used this one (almost the same one) as a template, but somewhere, I am screwing up. One of the problems is the one with the network path portion.
     
    sashk, Jun 3, 2004
    #4
  5. sashk

    T.Willey Guest

    (vl-load-com)
    (setq pref_obj (vla-get-Files (vla-get-Preferences (vlax-get-acad-object))))
    (setq old_path (vla-get-PrinterStyleSheetPath pref_obj))
    (vl-catch-all-apply 'vla-put-PrinterStyleSheetPath (list pref_obj (strcat old_path "123")))

    I found this on someother website. It seemed to work. The website was not in english, but if you want it it's.
    http://www.autocad.ru/cgi-bin/f1/board.cgi?t=3870RW

    Hope it helps.
    Tim
     
    T.Willey, Jun 3, 2004
    #5
  6. sashk

    andywatson Guest

    Sashk --

    I think I fixed your errors and have attached the file.

    2 problems:

    1. Your "if" statements were not constructed correctly.
    2. You were comparing string values of the paths which did not match in (a) the case of the letters <upper/lower> and (b) the directory slashes.
    Example:
    "c:\\Acad 2004" does not ever equal "C:/Acad 2004", eventhough they may both point to a valid directory ...therefore the changes you require never get made.

    I changed your program by
    1. Capitalizing the paths acquired from your "(vla-getfiles (vla-get-preferences)..." call to autocad using the (strcase function.
    2. Captilizing the comparison paths (the ones you are supplying) so that "C:\\ACAD 2004" WILL equal "C:\\ACAD 2004"
    2. Replaced the "/" in your comparison paths to "\\", which is what is normally returned by a path query.

    Let me know if you need any more help.
    Andrew
     
    andywatson, Jun 3, 2004
    #6
  7. sashk

    sashk Guest

    Thanks for the reply. I tried it. One probelm. It wont toggle.
    If on network path, then go to the M: drive

    If on M: drive, then go to the network.

    Can you help?

    Thanks
     
    sashk, Jun 3, 2004
    #7
  8. sashk

    andywatson Guest

    which way works and which way doesn't?
    network->M or M->network?
     
    andywatson, Jun 3, 2004
    #8
  9. sashk

    sashk Guest

    well, actually, both. It is really weird. If I manually set it to M:, then paste some of the code in to revert back to the network, it returns some invalid message and actually vise versa.

    I also had to add 2 more \\ to the network path because the
    !currentpath returned it as \\\\p2333-01........ not \\p2333-01
     
    sashk, Jun 3, 2004
    #9
  10. sashk

    andywatson Guest

    additionally...
    replace the following server path:
    \\P2333-01\\DECADR14DISTRIBUTION\\00DECAD\\QCAD2004\\QPLOTSTYLES04
    with this:
    \\\\P2333-01\\DECADR14DISTRIBUTION\\00DECAD\\QCAD2004\\QPLOTSTYLES04
    It requires two more slashes at the server root (4 total).
     
    andywatson, Jun 3, 2004
    #10
  11. sashk

    sashk Guest

    yep, got that part, but why wont it toggle?


    Sash
     
    sashk, Jun 3, 2004
    #11
  12. sashk

    sashk Guest

    Okay, I tried some stuff

    Right now, it is on the M: drive location. I manually pasted in:
    (if
    (= currentPath "M:\\ACAD 2004\\CONSULTANT PLOT STYLES")
    (progn
    (vla-put-PrinterStyleSheetPath files "\\\\P2333-01\\DECADR14DISTRIBUTION\\00DECAD\\QCAD2004\\QPLOTSTYLES04")
    )
    )

    to see if it would change the path to the network. It returned:
    error: Automation Error. Invalid Argument
     
    sashk, Jun 3, 2004
    #12
  13. sashk

    andywatson Guest

    That is the message that is returned if the specified directory doesn't exist. Make sure that it is spelled EXACTLY the same.

    What you might want to do is set it manually to the network path (through Options), run the routine and get the output of "Current Plot Style Path = " to the command line. Repeat after manually setting it to the M:\ directory.
     
    andywatson, Jun 3, 2004
    #13
  14. sashk

    andywatson Guest

    Furthermore, does it work from network to M?
     
    andywatson, Jun 3, 2004
    #14
  15. sashk

    sashk Guest

    Yes, I did do that. Looks correct. I even did a copy and paste, but still no luck
     
    sashk, Jun 3, 2004
    #15
  16. sashk

    sashk Guest

    no, it does not seem to work
     
    sashk, Jun 3, 2004
    #16
  17. sashk

    andywatson Guest

    Ok,
    Modified some stuff...changed your if statements to a conditional statement...
    (cond
    ;; first condition
    ((if <this is true>)
    (<then do this>)
    ); end of first condition

    ;; second condition
    ((if <this is true>)
    (<then do this>)
    ); end of second condition

    ); end of conditional statement

    This applies more to what you are trying to do, since only one of the conditions will be true.

    Here you go....make sure that the paths are correct in the "set network path" and "set m drive path"

    (defun c:FixPrinters (/ files pathNetwork pathMDrive)

    ;; Set the various print-related paths the Preferences\Files object
    ;; get the Files object in the Preferences Object
    (setq files
    (vla-get-files
    (vla-get-preferences
    (vlax-get-acad-object)
    )
    )
    ); end of setq

    ;; Set network path
    (setq pathNetwork "\\\\P2333-01\\DECADR14DISTRIBUTION\\00DECAD\\QCAD2004\\QPLOTSTYLES04")
    ;; Set M drive path
    (setq pathMDrive "M:\\ACAD 2004\\CONSULTANT PLOT STYLES")

    ;; set currentPath equal to current path
    ;; ***capitalize all letters since "C:\\ACAD 2004" does NOT equal "c:\\Acad 2004"
    (setq pathCurrent (strcase (vla-get-PrinterStyleSheetPath files)))

    ; display old settings
    (prompt "\nCurrent Plot Styles Path = ")
    (princ pathCurrent)

    ;; conditional statement...evaluates one of the following conditions
    (cond
    ;; if current path is M Drive path
    ((= pathCurrent pathMDrive)
    ;; change to network path
    (vla-put-PrinterStyleSheetPath files pathNetwork)
    )

    ;; if current path is network path
    ((= pathCurrent pathNetwork)
    ;; change to M Drive path
    (vla-put-PrinterStyleSheetPath files pathMDrive)
    )
    ); end of cond

    ; display new settings
    (prompt "\nNew Plot Styles Path = ")
    (princ (strcase (vla-get-PrinterStyleSheetPath files)))

    (princ); exit quietly (no garbage to command line)

    ); end of program
     
    andywatson, Jun 3, 2004
    #17
  18. sashk

    sashk Guest

    CLose.

    If I set my current path (through options) to my network, and then run the routine, it changes the path to the M: drive. So far, so good

    If I hit enter (to repeat and toggle the routine) so that it will path to the network, it says invalid arguement. This is where things are not working.

    Any more ideas. Your help is so appreciated! I appreciate your patience!

    Sash
     
    sashk, Jun 4, 2004
    #18
  19. sashk

    andywatson Guest

    Here's an idea...
    manually set your path to the network path (the one that is not working).
    Copy and paste the following code at the command line:
    (setq pathNetwork (strcase (vla-get-PrinterStyleSheetPath (vla-get-files (vla-get-preferences (vlax-get-acad-object))))))

    Then copy and paste this at the command line:
    (princ pathNetwork)(princ)

    Then copy and paste whatever it spit out into your next reply on this post so we can see it.
     
    andywatson, Jun 4, 2004
    #19
  20. sashk

    andywatson Guest

    Actually...if you see this in time....forget the
    (princ pathNetwork)(princ)
    just copy and paste the result of the longer statement in your next post.
     
    andywatson, Jun 4, 2004
    #20
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.