Support file search path

Discussion in 'AutoCAD' started by Bryan Thomson, Nov 4, 2004.

  1. I've found many answers to this problems by searching thru the web based
    format of this newsgroup but I still haven't been able to do what I want to
    do. I want a lisp routine that can add directories (multiple) to my support
    file search path under options. I would prefer to not do this with profiles.

    I have read a couple dozen solutions to this problem but all of them have
    been over my head. Im a little versed in autolisp but not even close to the
    level as some of the people on this board. Any help with this issue would be
    greatly appreciated
     
    Bryan Thomson, Nov 4, 2004
    #1
  2. Bryan Thomson

    Jeff Mishler Guest

    Try this:

    (setq newpaths ";C:\\MyPath1;C:\\MyPath2")

    (setenv "ACAD" (strcat (getenv "ACAD") newpaths))
     
    Jeff Mishler, Nov 4, 2004
    #2
  3. Bryan Thomson

    T.Willey Guest

    Bryan,

    Here is how I did it. Most of the code is gotten from people here, as I didn't write it.

    Tim

    (defun addSupportPath (dir pos / tmp c lst)
    ; AcadX
    ; Ex: (addsupportpath "c:\\custom" 0) put first in list of support directories

    (setq tmp ""
    c -1
    )
    (if (not (member (strcase dir) (setq lst (mapcar 'strcase (strParse (getenv "ACAD") ";")))))
    (progn
    (if (not pos)
    (setq tmp (strcat (getenv "ACAD") ";" dir))
    (mapcar
    '(lambda (x)
    (setq tmp
    (if (= (setq c (1+ c)) pos)
    (strcat tmp ";" dir ";" x)
    (strcat tmp ";" x)
    )
    )
    )
    lst
    )
    )
    (setenv "ACAD" tmp)
    )
    )
    (princ)
    )


    ;====================================

    (defun strParse (Str Delimiter / SearchStr StringLen return n char)
    ; AcadX
    ; Ex: (StrParse "Harp,Guiness,Black and Tan" ",") = ("Harp" "Guiness" "Black and Tan")

    (setq SearchStr Str)
    (setq StringLen (strlen SearchStr))
    (setq return '())
    (while (> StringLen 0)
    (setq n 1)
    (setq char (substr SearchStr 1 1))
    (while (and (/= char Delimiter) (/= char ""))
    (setq n (1+ n))
    (setq char (substr SearchStr n 1))
    ) ; end while
    (setq return (cons (substr SearchStr 1 (1- n)) return))
    (setq SearchStr (substr SearchStr (1+ n) StringLen))
    (setq StringLen (strlen SearchStr))
    ) ; end while
    (reverse return)
    )

    ---------- Then in my lisp I have this portion of code.

    (if (findfile "c:\\custom")
    (addsupportpath "c:\\custom" 0)
    (alert "Could not find \"Custom\" directory on \"C:\" dirve!")
    )
    (if (findfile "c:\\custom\\Drawings")
    (addsupportpath "c:\\custom\\Drawings" 2)
    (alert "Could not find \"Custom\\Drawings\" directory on \"C:\" dirve!")
    )


    Hope this helps.
     
    T.Willey, Nov 4, 2004
    #3
  4. That is exactly what I needed. Work perfectly. Thank you very much
     
    Bryan Thomson, Nov 4, 2004
    #4
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.