Modify Support Search Path- VBA

Modify Support Search Path- VBA

Anonymous
Not applicable
935 Views
6 Replies
Message 1 of 7

Modify Support Search Path- VBA

Anonymous
Not applicable
I want to first remove all teh paths specified in the "Support File Searcg Path" and then add my own paths.
I can add my own , BUT I CANNOT find a way to remove the existing ones.
I am using VBA.

Does anyone hae a snippet of code to get me going or point me in the right direction.

Thanks.
0 Likes
936 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
bilalakhan wrote:
> I want to first remove all teh paths specified in the "Support File Searcg Path" and then add my own paths.
> I can add my own , BUT I CANNOT find a way to remove the existing ones.
> I am using VBA.
>
> Does anyone hae a snippet of code to get me going or point me in the right direction.
>
> Thanks.

Just set the paths you need. It will overwrite whatever is
there. You do need to at least include the main support
directory (C:\Documents and Settings\[user]\Application
Data\Autodesk\[product]\[version]\[lang]\support)

If you needed to append, then you would grab what is there,
append the string, then push the string back.

--
R.K. McSwain
http://rkmcswain.blogspot.com
0 Likes
Message 3 of 7

Anonymous
Not applicable
Hi ,
Here an exemple in lisp (with DOSLIB!)
Daniel OLIVES
FRANCE-Lyon

[CODE]
(defun set_paths ()

;-------------------------------------------------------------------------------------------
; Définition du Path d'AutoCAD
;-------------------------------------------------------------------------------------------
(if (not (vl-bb-ref 'path_autocad))
(vl-bb-set 'path_autocad
(strcat
(vl-registry-read
(strcat
"HKEY_LOCAL_MACHINE\\"
(VLAX-PRODUCT-KEY)
)
"AcadLocation"
)
"\\"
)
)
)
;-------------------------------------------------------------------------------------------
; Définition du Path User d'AutoCAD
;-------------------------------------------------------------------------------------------
; RoamableRootFolder
; C:\Documents and Settings\dolives\Données d'applications\Autodesk\AutoCAD 2006\R16.2\fra\
; HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.2\ACAD-4001:40C
; (VLAX-PRODUCT-KEY) = "Software\\Autodesk\\AutoCAD\\R16.2\\ACAD-4001:40c"
(setq pathsupportuser
(strcat
(vl-registry-read
(strcat
"HKEY_CURRENT_USER\\"
(VLAX-PRODUCT-KEY)
)
"RoamableRootFolder"
)
"Support\\"
)
)
(if (not (vl-bb-ref 'path_support_user))
(vl-bb-set 'path_support_user pathsupportuser)
)

;-------------------------------------------------------------------------------------------
; Définition des répertoires d'AutoCAD (File Support Search Path)
;-------------------------------------------------------------------------------------------
; http://www.fr.emea.mcneel.com/news/0307pr.htm
; pour 2006 "C:\Program Files\AutoCAD 2006\Support\"
(if (not (dos_strmatch (getenv "ACAD") (strcat "*" (vl-bb-ref 'path_autocad) "Support*")))
(setenv "ACAD" (strcat (vl-bb-ref 'path_autocad) "Support;"(getenv "ACAD")))
)
; pour 2006 "C:\Program Files\AutoCAD 2006\Support\"
(if (not (dos_strmatch (getenv "ACAD") (strcat "*" (vl-bb-ref 'path_autocad) "Fonts*")))
(setenv "ACAD" (strcat (vl-bb-ref 'path_autocad) "Fonts;"(getenv "ACAD")))
)
; pour 2006 "C:\Program Files\AutoCAD 2006\Help\"
(if (not (dos_strmatch (getenv "ACAD") (strcat "*" (vl-bb-ref 'path_autocad) "Help*")))
(setenv "ACAD" (strcat (vl-bb-ref 'path_autocad) "Help;"(getenv "ACAD")))
)
; pour 2006 "C:\Program Files\AutoCAD 2006\Express\"
(if (not (dos_strmatch (getenv "ACAD") (strcat "*" (vl-bb-ref 'path_autocad) "Express*")))
(setenv "ACAD" (strcat (vl-bb-ref 'path_autocad) "Express;"(getenv "ACAD")))
)
; pour 2006 "C:\Program Files\AutoCAD 2006\Support\Color\"
(if (not (dos_strmatch (getenv "ACAD") (strcat "*" (vl-bb-ref 'path_autocad) "Support\\Color*")))
(setenv "ACAD" (strcat (vl-bb-ref 'path_autocad) "Support\\Color;"(getenv "ACAD")))
)
;------------------------------------------------------------------------------------------------------------
; pour 2006 "C:\Documents and Settings\dolives\Données d'applications\Autodesk\AutoCAD 2006\R16.2\fra\Support\"
(if (not (dos_strmatch (getenv "ACAD") (strcat "*" pathsupportuser "*")))
(setenv "ACAD" (strcat pathsupportuser ";" (getenv "ACAD")))
)
;------------------------------------------------------------------------------------------------------------
; pour "C:\TPS\Acad\Routines"
(if (not (dos_strmatch (getenv "ACAD") (strcat "C:\TPS\Acad\Routines")))
(setenv "ACAD" (strcat (getenv "ACAD") ";" "C:\\TPS\\Acad\\Routines"))
)
(princ)
;------------------------------------------------------------------------------------------------------------
; pour "C:\Program Files\Egid\Cache"
(if (not (dos_strmatch (getenv "ACAD") (strcat "C:\Program Files\Egid\Cache")))
(setenv "ACAD" (strcat (getenv "ACAD") ";" "C:\\Program Files\\Egid\\Cache"))
)
(princ)
;-------------------------------------------------------------------------------------------
; Définition des répertoires des 'Template' = GABARIT
;-------------------------------------------------------------------------------------------
; O:\ACAD\param\Template
;
(setenv "TemplatePath" "O:\\ACAD\\param\\Template")
(princ "\n TemplatePath = O:\\ACAD\\param\\Template")
(setenv "QnewTemplate" "O:\\ACAD\\param\\Template\Egid_acad.dwt")
(princ "\n QnewTemplate = O:\\ACAD\\param\\Template\\Egid_acad.dwt")
;-------------------------------------------------------------------------------------------
; Définition du répertoire des XREFS
;-------------------------------------------------------------------------------------------
(setvar "XLOADPATH" "C:\\Program Files\\Egid\\Cache\\")
(princ "\n XLOADPATH = C:\\Program Files\\Egid\\Cache\\")
(setvar "visretain" 1)
(princ "\n VISRETAIN = 1")
(setvar "xreftype" 1)
(princ "\n XREFTYPE = 1")
(setvar "xrefnotify" 2)
(princ "\n XREFNOTIFY = 2")
; TRAYNOTIFY = 1
; TRAYTIMEOUT = 0 à 10 secondes
; n en minutes = 1 --> 10 080 (soit 7 jours)
(setenv "XNOTIFYTIME" "10")
(princ "\n XNOTIFYTIME = 10 minutes")

;-------------------------------------------------------------------------------------------
; Définition de la FONT alternative
;-------------------------------------------------------------------------------------------
(setvar "fontalt" "romanc.shx")
(princ "\n FONTALT = ROMAN.shx")
;-------------------------------------------------------------------------------------------
; Définition de la variable "XLOADCTL" a 2 soit chargement des xrefs !
;-------------------------------------------------------------------------------------------
(SetPathType "2")
(princ "\n SETPATHTYPE =2")
;-------------------------------------------------------------------------------------------
; Définition du menu entreprise "TPS.cui" s'il existe !
;-------------------------------------------------------------------------------------------
;(Set menuEnt (getenv "EnterpriseMenuFile")) ; si aucun " . "
;(if (= MenuEnt " . ")
; (setenv "EnterpriseMenuFile" "O:\\Acad\\Param\\Menu_entreprise\\TPS.cui")
;)
)
0 Likes
Message 4 of 7

Anonymous
Not applicable
This should give you everything you need. This function removes a path and replaces it with a new one within the search path semi-colon delimited string.

Private Function spChange(oldPath As String, _
newPath As String)
Dim acadPref As AcadPreferencesFiles
Dim pathAry() As String
Dim oldStr As String, newStr As String
Dim i As Integer

Set acadPref = AcadApplication.Preferences.Files
oldStr = acadPref.SupportPath
pathAry = Split(oldPath, ";")

For i = LBound(pathAry) To UBound(pathAry)
If pathAry(i) = oldPath Then pathAry(i) = Trim(newPath)
Next i

For i = LBound(pathAry) To UBound(pathAry)
newStr = Trim(newStr) & Trim(pathAry(i)) & ";"
Next i

newStr = Trim(Replace(Left(newStr, Len(newStr) - 1), ";;", ";"))
acadPref.SupportPath = newStr

Erase pathAry
Set acadPref = Nothing

End Function
0 Likes
Message 5 of 7

Anonymous
Not applicable
I tried one similar after seeing pervious post and could not find anything
to set a new item to the path, I could however get current settings

I found this to get the string items

Public Function GetSupportPaths() As Variant
Dim strPrefsFiles As String
strPrefsFiles = ThisDrawing.Application.preferences.Files
GetSupportPaths = Split(strPrefsFiles, ";")
End Function


I tried
dim addsupportPath as string
addsupportPath = "c:\temp"
preferences.Files.SupportPath = addSupportPath

but that removed all the existing strings items and wrote on the
addSupportPath string

it was fun trying

John



wrote in message news:5814896@discussion.autodesk.com...
This should give you everything you need. This function removes a path and
replaces it with a new one within the search path semi-colon delimited
string.

Private Function spChange(oldPath As String, _
newPath As String)
Dim acadPref As AcadPreferencesFiles
Dim pathAry() As String
Dim oldStr As String, newStr As String
Dim i As Integer

Set acadPref = AcadApplication.Preferences.Files
oldStr = acadPref.SupportPath
pathAry = Split(oldPath, ";")

For i = LBound(pathAry) To UBound(pathAry)
If pathAry(i) = oldPath Then pathAry(i) = Trim(newPath)
Next i

For i = LBound(pathAry) To UBound(pathAry)
newStr = Trim(newStr) & Trim(pathAry(i)) & ";"
Next i

newStr = Trim(Replace(Left(newStr, Len(newStr) - 1), ";;", ";"))
acadPref.SupportPath = newStr

Erase pathAry
Set acadPref = Nothing

End Function
0 Likes
Message 6 of 7

Anonymous
Not applicable
All you need to know is in the function I gave you above.

A few things that you may be misunderstanding:
There is a "Support File Search Path" and a "Working File Search Path"

When you ask for the search paths, it returns the "Working Support File Search Paths". When you set a new path, it writes to the "Support File Search Path". Having the program return the paths again will not show the newly added path because it doesn't exist therefore is not a "working" path. Take this example:

'~~~START CODE
Sub testss()
Dim acadPref As AcadPreferencesFiles
Dim oldPaths As String
Dim newPath As String
newPath = "C:\New Folder"
Set acadPref = AcadApplication.Preferences.Files
oldPaths = acadPref.SupportPath
Debug.Print oldPaths
newPath = oldPaths & ";" & newPath
acadPref.SupportPath = newPath
Debug.Print acadPref.SupportPath
End Sub

'~~~~END CODE

If you run that, then look in your options dialog in AutoCAD, you will see that the path got added to the "Support File Search Path". You will also notice that the "Working File Search Path" does not contain the new path (assuming the path doesn't exist on your computer). So this does work, as I use it in a few applications.

The VBA object model does not seem to expose the actual "Support File Search Path", it seems to only return the "Working File Search Path". I would imagine there are other ways to get the actual "Support File Search Path", such as the registry, but I am unaware of it.

The only time this is a PITA, is if your network structure changes, and some working paths stop working and you run a program which changes these parameters. You may not get the intended result then.
0 Likes
Message 7 of 7

Anonymous
Not applicable
rsstrqndmark,

Thank you for the explanation, I'll try it a work today.

John
wrote in message news:5815390@discussion.autodesk.com...
All you need to know is in the function I gave you above.

A few things that you may be misunderstanding:
There is a "Support File Search Path" and a "Working File Search Path"

When you ask for the search paths, it returns the "Working Support File
Search Paths". When you set a new path, it writes to the "Support File
Search Path". Having the program return the paths again will not show the
newly added path because it doesn't exist therefore is not a "working" path.
Take this example:

'~~~START CODE
Sub testss()
Dim acadPref As AcadPreferencesFiles
Dim oldPaths As String
Dim newPath As String
newPath = "C:\New Folder"
Set acadPref = AcadApplication.Preferences.Files
oldPaths = acadPref.SupportPath
Debug.Print oldPaths
newPath = oldPaths & ";" & newPath
acadPref.SupportPath = newPath
Debug.Print acadPref.SupportPath
End Sub

'~~~~END CODE

If you run that, then look in your options dialog in AutoCAD, you will see
that the path got added to the "Support File Search Path". You will also
notice that the "Working File Search Path" does not contain the new path
(assuming the path doesn't exist on your computer). So this does work, as I
use it in a few applications.

The VBA object model does not seem to expose the actual "Support File Search
Path", it seems to only return the "Working File Search Path". I would
imagine there are other ways to get the actual "Support File Search Path",
such as the registry, but I am unaware of it.

The only time this is a PITA, is if your network structure changes, and some
working paths stop working and you run a program which changes these
parameters. You may not get the intended result then.
0 Likes