support file search path - add at once

support file search path - add at once

Anonymous
Not applicable
1,575 Views
3 Replies
Message 1 of 4

support file search path - add at once

Anonymous
Not applicable

hi everyone. I am really helped this site. thank you all.

I have folders and lisps

 

folders ==>

archi

autokey

crossert

hatch maker

labuild

lisp1

npplisp

scripts

etc...

 

I want to add these folders at <support file search path> at once.

let me know. plz... 

0 Likes
1,576 Views
3 Replies
Replies (3)
Message 2 of 4

hmsilva
Mentor
Mentor

@Anonymous wrote:

hi everyone. I am really helped this site. thank you all.

I have folders and lisps

 

folders ==>

archi

autokey

crossert

hatch maker

labuild

lisp1

npplisp

scripts

etc...

 

I want to add these folders at <support file search path> at once.

let me know. plz... 


Hello cdtemp and welcome to the Autodesk Community!

 

Try

 

;; get files from preferences
(setq Files (vlax-get (vlax-get (vlax-get-acad-object)"Preferences") "Files"))
;; get actual SupportPath from files
(setq SuppPath (vlax-get Files "SupportPath"))
;; set the new SupportPath
(setq NewSuppPath (strcat Files ";The:\\full\\path\\archi;The:\\full\\path\\autokey;....all the new folders..."))
;; put the NewSuppPath to the Files
(vlax-put Files "SupportPath" NewSuppPath)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 4

m_badran
Advocate
Advocate

This maybe help but I don't know who is author.

(defun c:SFSP  (/ OSHELL)
  (vl-load-com)
  (defun *error*  (msg)
    (if oShell
      (setq oShell (vlax-release-object oShell)))
    (cond ((not msg))                                                   ; Normal exit
          ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
          ((princ (strcat "\n** Error: " msg " ** "))))                 ; Fatal error, display it
    (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ((lambda (acApp / oShell oFolder acDoc acFiles path oldPath)
     (if
       (and
         (setq oShell
                (vlax-get-or-create-object "Shell.Application"))
         (setq oFolder
                (vlax-invoke
                  oShell
                  'BrowseForFolder
                  (vla-get-hwnd acApp)
                  "Select a folder to add to SFSP:"
                  0
                  17)))
        (if
          (not
            (vl-string-search
              (strcase
                (setq path
                       (strcat
                         (vlax-get-property
                           (vlax-get-property oFolder 'Self)
                           'Path)
                         ";")))
              (strcase
                (setq oldPath
                       (strcat
                         (vl-string-right-trim
                           ";"
                           (vla-get-supportpath
                             (setq acFiles
                                    (vla-get-files
                                      (vla-get-preferences
                                        acApp)))))
                         ";")))))
           (progn
             (vla-put-supportpath acFiles (strcat oldPath ";" path))
             (*error* nil))
           (*error* "Path already exists in SFSP"))
        (cond
          (oShell (*error* nil))
          ((*error* "Unable to create Shell.Application Object")))))
    (vlax-get-acad-object))
  )

 

Message 4 of 4

joselggalan
Advocate
Advocate

try this:

 

function:

(defun Add_Path_To_Acad (strRuta / pathAcad Retval)
 (setq strRuta (vl-string-right-trim "\\" strRuta))
 (cond
  ((vl-file-directory-p strRuta)
   (setq pathAcad (getenv "ACAD"))
   (cond
    ;;Path found at the end of the string
    ((wcmatch (strcase pathAcad) (strcat "*;" (strcase strRuta)))
     (setq Retval 0)
    )
    ;;Path was found in the middle of the chain
    ((wcmatch (strcase pathAcad) (strcat "*" (strcase strRuta) ";*"))
     (setq Retval 0)
    )
    ;;NO FOUND path, register:
    (t
     (setenv "ACAD" (setq pathAcad (strcat pathAcad ";" strRuta)))
     (setq Retval 1)
    )
   )
  )
 )
 Retval
)

test:

(defun c:tst_Add_path ()
 ((lambda (fun)
   (fun '("E:\\PROGRAM\\000_Pruebas"
	  "E:\\PROGRAM\\Acadinstall"
	  "E:\\PROGRAM\\2DrawArch"
	  "E:\\PROGRAM\\NotFound"
	 )
   )
  )
  (lambda (mlst / path reg)
     (cond
      ((not (setq path (car mlst))))
      (T
       (cond
	((not (setq reg (Add_Path_To_Acad path)))(princ (strcat "\n Path: [" path "]. Not found.")))
	((= reg 0)(princ (strcat "\n Path: [" path "]. Was already registered.")))
	((= reg 1)(princ (strcat "\n Path: [" path "]. registered OK.")))
       )
       (fun (cdr mlst))
      )
     )
    )
 )
 (princ)
)

result:

 

 Path: [E:\PROGRAM\000_Pruebas]. Was already registered.
 Path: [E:\PROGRAM\Acadinstall]. registered OK.
 Path: [E:\PROGRAM\2DrawArch]. registered OK.
 Path: [E:\PROGRAM\NotFound]. Not found.