Adding Multiple supprt paths?? Help

Discussion in 'AutoCAD' started by Chris Chiles, Feb 11, 2005.

  1. Chris Chiles

    Chris Chiles Guest

    I have search the newsgroups all over and found alot of very helpful info.
    What I have so far works - with one support path. I need to add about 6.

    Here's what I have from the info I found:

    **addsupportpath.lsp**
    --------------------------------------------------------------------------------------------------------------------------------
    (defun addSupportPath (dir pos / tmp c lst)
    (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)
    )
    --------------------------------------------------------------------------------------------------------------------------------



    I have this lisp in my "lisp" folder

    **StrParse.lsp**
    --------------------------------------------------------------------------------------------------------------------------------
    ;;;==================================================================<
    br>;;; (StrParse Str Delimiter)
    ;;; Parses a delimited string into a list
    ;;;------------------------------------------------------------------;;;
    Parameters:
    ;;; Str String to parse
    ;;; Delimiter Delimiter to search for
    ;;;------------------------------------------------------------------
    ;;; Returns:
    ;;; A list strings.
    ;;; ex:
    ;;; (setq a "Harp,Guiness,Black and Tan")
    ;;; (StrParse a ",")
    ;;; returns:
    ;;; ("Harp" "Guiness" "Black and Tan")
    ;;;------------------------------------------------------------------<
    br>;;; See Also: (StringToList)
    ;;;---------------------------------------------------------- --------
    (defun strParse (Str Delimiter / SearchStr StringLen return n char)
    (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 of while
    (setq return (cons (substr SearchStr 1 (1- n)) return))
    (setq SearchStr (substr SearchStr (1+ n) StringLen))
    (setq StringLen (strlen SearchStr))
    ) ;_ end of while
    (reverse return)
    ) ;_ end of defun
    --------------------------------------------------------------------------------------------------------------------------------




    **supportpathlist.lsp**
    --------------------------------------------------------------------------------------------------------------------------------
    (load "addsupportpath.lsp")
    (addSupportPath "c:\\myFolder" 2)
    --------------------------------------------------------------------------------------------------------------------------------

    All that works Great - But I can't figure out how to add more than one path
    to "supportpathlist.lsp". Can anyone help me?

    Thanks,
    Chris
     
    Chris Chiles, Feb 11, 2005
    #1
  2. Chris Chiles

    TomD Guest

    You may get more help on lisp in the customization group.

    Here's one I've had laying around for some time. All I can tell you is that
    it works. I would not suggest that it is the best solution. I can't
    remember where I got this, exactly, though I think it was part of the
    AutoDesk stuff (maybe from "bonus tools"), circa R14.

    ;;;---------------------------------------------------------->>add_path
    ;Nested function, adds 'dir' argument to AutoCAD search
    ;path if not already present.
    ;Returns the AutoCAD search path if the dir argument was added or nil if
    not.
    (defun add_path ( dir / a b c)
    (if (and dir
    (setq c (getenv "ACAD"))
    );and
    (progn
    ;prepare to look for 'dir' within the AutoCAD search path
    (setq a (strcase c)
    b (strcase dir)
    );setq
    ;;Removed by TLD 1/98 - WHY WOULD YOU ADD A ; AT THE FRONT OF ACAD
    Path?!?!?!?
    ; (if (not (equal ";" (substr a 1 1)))
    ; (setq a (strcat ";" a));add a ";" in front of the string if not
    already present
    ; );if

    (if (not (equal ";" (substr a (strlen a) 1)))
    (setq a (strcat a ";")
    c (strcat c ";");add a trailing ";" if not already present
    );setq
    );if
    (if (not (wcmatch a (strcat "*;" b ";*"))) ;is 'dir' already present
    in search path?
    (progn
    (setq c (strcat c dir));setq
    (setenv "ACAD" c)
    );progn
    (setq c nil)
    );if
    );progn then
    (setq c nil)
    );if
    c
    );defun add_path
     
    TomD, Feb 11, 2005
    #2
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.