Try this Serge:
[color=GREEN];;---------------=={ Add Support Paths at N }==---------------;;[/color]
[color=GREEN];; ;;[/color]
[color=GREEN];; Adds a list of Support Paths to those listed in the ;;[/color]
[color=GREEN];; AutoCAD Support Path property, excluding duplicates. ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];; Arguments: ;;[/color]
[color=GREEN];; lst - List of Support Paths to Add ("C:\\Folder" ... ) ;;[/color]
[color=GREEN];; n - [optional] zero-based position at which to add ;;[/color]
[color=GREEN];; new support paths, if nil, paths are added to start ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];; Returns: List of added Support Paths ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
([color=BLUE]defun[/color] LM:AddSupportPathsAtN ( lst n [color=BLUE]/[/color] _lst->str _str->lst _putNth PreferenceFiles SupportPaths ) ([color=BLUE]vl-load-com[/color])
([color=BLUE]defun[/color] _lst->str ( lst del )
([color=BLUE]if[/color] ([color=BLUE]cdr[/color] lst)
([color=BLUE]strcat[/color] ([color=BLUE]car[/color] lst) del (_lst->str ([color=BLUE]cdr[/color] lst) del))
([color=BLUE]car[/color] lst)
)
)
([color=BLUE]defun[/color] _str->lst ( str del [color=BLUE]/[/color] pos )
([color=BLUE]if[/color] ([color=BLUE]setq[/color] pos ([color=BLUE]vl-string-search[/color] del str))
([color=BLUE]vl-remove[/color] [color=MAROON]""[/color] ([color=BLUE]cons[/color] ([color=BLUE]substr[/color] str 1 pos) (_str->lst ([color=BLUE]substr[/color] str ([color=BLUE]+[/color] pos 1 ([color=BLUE]strlen[/color] del))) del)))
([color=BLUE]list[/color] str)
)
)
([color=BLUE]defun[/color] _putNth ( a n l )
([color=BLUE]if[/color] ([color=BLUE]and[/color] l ([color=BLUE]<[/color] 0 n))
([color=BLUE]cons[/color] ([color=BLUE]car[/color] l) (_putNth a ([color=BLUE]1-[/color] n) ([color=BLUE]cdr[/color] l)))
([color=BLUE]cons[/color] a l)
)
)
([color=BLUE]setq[/color] PreferenceFiles ([color=BLUE]vla-get-files[/color] ([color=BLUE]vla-get-preferences[/color] ([color=BLUE]vlax-get-acad-object[/color])))
SupportPaths (_str->lst ([color=BLUE]vla-get-SupportPath[/color] PreferenceFiles) [color=MAROON]";"[/color])
)
([color=BLUE]vla-put-SupportPath[/color] PreferenceFiles
(_lst->str
([color=BLUE]apply[/color] '[color=BLUE]append[/color]
(_putNth
([color=BLUE]setq[/color] lst
([color=BLUE]vl-remove-if[/color] '([color=BLUE]lambda[/color] ( s ) ([color=BLUE]member[/color] s SupportPaths)) lst)
)
n ([color=BLUE]mapcar[/color] '[color=BLUE]list[/color] SupportPaths)
)
)
[color=MAROON]";"[/color]
)
)
lst
)
Example Function call:
(LM:AddSupportPathsAtN '("C:\\Folder" "C:\\Folder\\SubFolder") 4)
Position is zero-based, consistent with LISP list functions, if position argument is nil folders are added to the top of the tree.
Lee