TheSwamp

Code Red => VB(A) => Topic started by: Matersammichman on October 25, 2006, 10:52:57 AM

Title: Support File Search Path
Post 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:
Title: Re: Support File Search Path
Post by: MP on October 25, 2006, 11:20:40 AM
Programmer's responsibility to ensure they provide qualified paths; don't duplicate paths etc.

Code: [Select]
(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
        )   
    )
)
Title: Re: Support File Search Path
Post by: Matersammichman on October 25, 2006, 11:26:12 AM
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)
Title: Re: Support File Search Path
Post by: Guest on October 25, 2006, 11:32:51 AM
Quote
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.

Quote
(not that I'm being picky or anything)
You sure are!   :-D
Title: Re: Support File Search Path
Post by: Greg B on October 25, 2006, 11:36:19 AM
Quote
(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:
Title: Re: Support File Search Path
Post by: Guest on October 25, 2006, 11:42:28 AM
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.
Title: Re: Support File Search Path
Post by: MP on October 25, 2006, 12:10:24 PM
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. :(
Title: Re: Support File Search Path
Post by: deegeecees on October 25, 2006, 01:21:41 PM
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.
Title: Re: Support File Search Path
Post by: Matersammichman on October 25, 2006, 01:23:01 PM
I did.
It's not saved there.
Title: Re: Support File Search Path
Post by: deegeecees on October 25, 2006, 01:30:34 PM
Hmmm... Interesting. What version Acad?
Title: Re: Support File Search Path
Post by: Matersammichman on October 25, 2006, 01:32:04 PM
ADT2005 w/SP2
Title: Re: Support File Search Path
Post by: David Hall on October 25, 2006, 01:32:26 PM
Its saved in a profile if you export your profile.  What you need to do is set a varible and append to it.
Title: Re: Support File Search Path
Post by: David Hall on October 25, 2006, 01:32:47 PM
here is code to do what you want
Code: [Select]
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
Title: Re: Support File Search Path
Post by: David Hall on October 25, 2006, 01:33:58 PM
I set supppath = the support path, then append by using
supppath & ";" & "path im adding"
Title: Re: Support File Search Path
Post by: deegeecees on October 25, 2006, 01:34:18 PM
Well, *head scratch* I'm lost there, my profiles in 2002 save support paths.

But, I just got this from CmdrDuh:

Code: [Select]
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
Title: Re: Support File Search Path
Post by: deegeecees on October 25, 2006, 01:34:47 PM
Oooooops, too slooooowwww....
Title: Re: Support File Search Path
Post by: Matersammichman on October 25, 2006, 01:36:18 PM
Yes, it saves "Support paths", but NOT "WORKING file support paths". They appear to be linked into the Support Paths, but non-editable directly.
Title: Re: Support File Search Path
Post by: David Hall on October 25, 2006, 01:36:44 PM
nah, I just copy paste faster than you.  BTW, did you get yous working?
Title: Re: Support File Search Path
Post by: David Hall on October 25, 2006, 01:37:30 PM
Working paths are what you get after you hit apply and Acad resolves whether you put in valid paths
Title: Re: Support File Search Path
Post by: Matersammichman on October 25, 2006, 01:40:01 PM
Correct.
Unfortunately, when I deleted\overwrote the "Support" paths, it did not update the "Working" paths.
Title: Re: Support File Search Path
Post by: deegeecees on October 25, 2006, 01:42:38 PM
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.
Title: Re: Support File Search Path
Post by: Matersammichman on October 25, 2006, 02:10:25 PM
'''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???
Title: Re: Support File Search Path
Post by: MP on October 25, 2006, 02:27:01 PM
Duplications due to case and slash characters is why I have entries like this in my lisp library --

Code: [Select]
(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 --

Code: [Select]
(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.

:)
Title: Re: Support File Search Path
Post by: David Hall on October 25, 2006, 02:33:20 PM
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
Code: [Select]
  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
Title: Re: Support File Search Path
Post by: Matersammichman on October 25, 2006, 02:33:51 PM
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.
Title: Re: Support File Search Path
Post by: David Hall on October 25, 2006, 02:34:55 PM
See my above post
Title: Re: Support File Search Path
Post by: Matersammichman on October 25, 2006, 02:36:10 PM
I think we were typing at the same time.
Thanks again swampers!