TheSwamp
Code Red => VB(A) => Topic started by: Matersammichman on October 25, 2006, 10:52:57 AM
-
Looking for code to add a path to my Support File Search Path (without deleting or overwriting existing paths), AND update the info in the Working Support File Search Path. :-P
I tried it yesterday. I accidentally deleted my existing paths...that takes a little while to recover from. Geez! Where the heck is that data saved- In the Registry??? :lol:
-
Programmer's responsibility to ensure they provide qualified paths; don't duplicate paths etc.
(defun _AddSupportPath ( path / files )
(vla-put-supportpath
(setq files
(vla-get-files
(vla-get-preferences
(vlax-get-acad-object)
)
)
)
(strcat
(vla-get-supportpath files) ";"
path
)
)
)
-
MP....Ummm...not sure I understand your comments, and
...oooops!!!
I meant to specifically state, I would really like the code to be in vba.
(not that I'm being picky or anything)
-
I meant to specifically state, I would really like the code to be in vba.
Wasn't there sumpin' just the other day regarding this?? Had to do with changing settings using an EXE?? If I find it, I'll post the link.
(not that I'm being picky or anything)
You sure are! :-D
-
(not that I'm being picky or anything)
You sure are! :-D
No he isn't...he did post it in the VB(A) forum. :police:
-
Here's the link: http://www.theswamp.org/index.php?topic=13146.0 (http://www.theswamp.org/index.php?topic=13146.0)
Maybe this'll get you going in the right direction.
-
MP....Ummm...not sure I understand your comments, and
...oooops!!!
I meant to specifically state, I would really like the code to be in vba.
(not that I'm being picky or anything)
Sorry: My bad, not fully awake. :(
-
I tried it yesterday. I accidentally deleted my existing paths...that takes a little while to recover from. Geez! Where the heck is that data saved- In the Registry??? :lol:
Save a Profile.
-
I did.
It's not saved there.
-
Hmmm... Interesting. What version Acad?
-
ADT2005 w/SP2
-
Its saved in a profile if you export your profile. What you need to do is set a varible and append to it.
-
here is code to do what you want
Public Sub ACADStartup()
Dim supppath As String
supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
'This will prevent you entering the same entry more than once
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
-
I set supppath = the support path, then append by using
supppath & ";" & "path im adding"
-
Well, *head scratch* I'm lost there, my profiles in 2002 save support paths.
But, I just got this from CmdrDuh:
Public Sub ACADStartup()
Dim supppath As String
supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
'This will prevent you entering the same entry more than once
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
-
Oooooops, too slooooowwww....
-
Yes, it saves "Support paths", but NOT "WORKING file support paths". They appear to be linked into the Support Paths, but non-editable directly.
-
nah, I just copy paste faster than you. BTW, did you get yous working?
-
Working paths are what you get after you hit apply and Acad resolves whether you put in valid paths
-
Correct.
Unfortunately, when I deleted\overwrote the "Support" paths, it did not update the "Working" paths.
-
nah, I just copy paste faster than you. BTW, did you get yous working?
"Swamped" at the moment. Barely have time to type this. Its on the back burner for now. Just not enough time in the day some times, lunchtime is the only time I have to myself.
-
'''Thanks guys, I was using that code to start with yesterday, but there's still a problem. Here is the exact code I am using:
Dim supppath3 As String
supppath3 =
UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
If Not (InStr(1, supppath3, "G:\Arc\CAD System\Template") > 1) Then
ThisDrawing.Application.Preferences.Files.SupportPath =
supppath3 & ";" & "G:\Arc\CAD System\Template"
End If
Exit Sub
'''what happens is that it will put it in the Support path once as UCase, and once as LCase. Why???
-
Duplications due to case and slash characters is why I have entries like this in my lisp library --
(defun _Replace ( oldText newText text / i )
(if (/= oldText newText)
(while (setq i (vl-string-search oldText text))
(setq text
(vl-string-subst
newText
oldText
text
i
)
)
)
)
text
)
And then this --
(defun _AddStr ( str1 str2 delim )
;; add str2 to the end of str1 if str2 doesn't exist in str1 (case
;; and slash insensitive) -- put delim between str1 and str2
( (lambda ( string pattern )
(if
(null
(or
(wcmatch string pattern)
(wcmatch string (strcat pattern delim "*"))
(wcmatch string (strcat "*" delim pattern delim "*"))
(wcmatch string (strcat "*" delim pattern))
)
)
(strcat str1 delim str2)
str1
)
)
(strcase (_Replace "/" "\\" str2))
(strcase (_Replace "/" "\\" str1))
)
)
Feel free to convert to equivalent VB code. I'd do it but (1) headache (2) too sleepy, even though it's admittedly a trivial task.
:)
-
It is put in in lower case the first time, then the second time through, It converts it to upper case, and when the check is run to see if its there, it doesn't find it (I know its there, but upper and lower are treated as different cases)
The way to fix your problem is when you add the path, use all upper case
supppath3 =
UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
If Not (InStr(1, supppath3, "G:\Arc\CAD System\Template") > 1) Then
ThisDrawing.Application.Preferences.Files.SupportPath =
supppath3 & ";" & "G:\ARC\CAD SYSTEM\TEMPLATE" ' ADDED THIS LINE
-
Actually, I really appreciate all the help.
I just resolved my own dilemma. WooHoo!!!
Here's the deal:
For whatever reason, vba writes into the Support paths (and all the others as well) all in CAPS. If your code is written in anything else (mixed, or lower case), you will get two entries in your paths: One in whatever case your code is written in, and one in all caps.
-
See my above post
-
I think we were typing at the same time.
Thanks again swampers!