Author Topic: Adding a support path using VBA  (Read 2051 times)

0 Members and 1 Guest are viewing this topic.

iliekater

  • Guest
Adding a support path using VBA
« on: December 11, 2006, 05:01:46 PM »
Is it possible to add a support path by using code ? Either with VBA or Lisp ?
« Last Edit: December 19, 2006, 04:03:37 PM by CmdrDuh »

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Adding a support path
« Reply #1 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

iliekater

  • Guest
Re: Adding a support path
« Reply #2 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
« Last Edit: December 12, 2006, 09:25:18 AM by Maverick® »

iliekater

  • Guest
Re: Adding a support path
« Reply #3 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 \\

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Adding a support path
« Reply #4 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
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

iliekater

  • Guest
Re: Adding a support path
« Reply #5 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 .