TheSwamp

Code Red => VB(A) => Topic started by: iliekater on December 11, 2006, 05:01:46 PM

Title: Adding a support path using VBA
Post by: iliekater on December 11, 2006, 05:01:46 PM
Is it possible to add a support path by using code ? Either with VBA or Lisp ?
Title: Re: Adding a support path
Post by: rkmcswain on December 11, 2006, 05:34:08 PM
Sure.

If you just want to ADD one, you would grab what is there, append to it, then replace the whole string.

Here is a LISP example: http://discussion.autodesk.com/thread.jspa?messageID=4982432
Title: Re: Adding a support path
Post by: iliekater on December 12, 2006, 08:57:27 AM
I found something I firstly found a ew years ago ! The code is from AfraLisp (now located on http://www.afralisp.net/) and it was copied there from http://www.acadx.com/
  It goes like this :

Code: [Select]
(defun addSP (dir pos / tmp c lst)
  (setq tmp ""
c   -1
  )
  (if
    (not
      (member (strcase dir)
      (setq lst (mapcar 'strcase (parse (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 parse (str delim / lst pos)
  (setq pos (vl-string-search delim str))
  (while pos
    (setq lst (cons (substr str 1 pos) lst)
  str (substr str (+ pos 2))
  pos (vl-string-search delim str)
    )
  )
  (if (> (strlen str) 0)
    (setq lst (cons str lst))
  )
  (reverse lst)
)


  Arguments : A folder path and the position at which to insert it. (0 based.)
  Here's an example to add a support folder :
(addSP "c:\\afralisp" 3)

I , personally , added in the lisp file the following in order to call it directly an set my support paths :

( defun c:LoadMySupportPaths ( )
  ( addSP "c:\\Windows" 0)
  ( addSP "d:\\Windows" 1)
)

<edit> added code tags  Mav
Title: Re: Adding a support path
Post by: iliekater on December 12, 2006, 09:15:40 AM
I forgot , above , to mention something very important :
If you use Lisp , don't use the \ character in order to separate folders . Instead use \\
Title: Re: Adding a support path
Post by: David Hall on December 12, 2006, 09:49:14 AM
and in VBA
Code: [Select]
Public Sub ACADStartup()
    Dim supppath As String

    'This will prevent you entering the same entry more than once
    supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
    If Not (InStr(1, supppath, "U:\TITLEBLOCKS") > 1) Then
        ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\TITLEBLOCKS"
    End If

    supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
    If Not (InStr(1, supppath, "U:\SYMBOLS") > 1) Then
        ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\SYMBOLS"
    End If

    supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
    If Not (InStr(1, supppath, "U:\PROJECTLOGS") > 1) Then
        ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\PROJECTLOGS"
    End If

    Exit Sub
End Sub
Title: Re: Adding a support path
Post by: iliekater on December 12, 2006, 05:53:00 PM
Reviewing my post above , in which I presented a code I found about adding support paths , I got the filling that I might get missunderstood . When I wrote "I , personally , added in the lisp file ...." , I didn't mean to overestimate myshelf . I just wanted to say that I simply had the idea of adding some lines and made my thought common , becouse it might interest others too . It's been many years since I spoke english very well , so please excuse me if sometimes I don't exprimate myshelf correctly .