Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations JAE on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear File Locations Entered in System Options

Status
Not open for further replies.

rjason71

Mechanical
Joined
Feb 23, 2007
Messages
132
Location
US
Does anyone know how to clear out all the file location entries in system options? I would like to create a macro to enter all the correct file locations on the server whenever there is a new installation of SWorks done. I can add locations but I can't figure out how to delete the ones already there.

Thanks.
 
It's really very simple. The file locations are stored as strings. Multiple locations are stored separated by a semicolon. So if your Weldment Profiles location list looks like

M:\SolidStd\profiles
C:\Program Files\SolidWorks\data\weldment profiles

the stored string is M:\SolidStd\profiles;C:\Program Files\SolidWorks\data\weldment profiles.

You can retrieve and set these values very simply. Here's a macro to read the current weldment profiles list and add an additionallocation:

Code:
Dim swApp As SldWorks.SldWorks
Sub main()
Dim OldLocations As String
Dim NewLocation As String
Set swApp = Application.SldWorks

NewLocation = "C:\MyWeldmentProfiles"

OldLocations = swApp.GetUserPreferenceStringValue(swFileLocationsWeldmentProfiles)
NewLocation = NewLocation & ";" & OldLocations
swApp.SetUserPreferenceStringValue swFileLocationsWeldmentProfiles, NewLocation

Debug.Print swApp.GetUserPreferenceStringValue(swFileLocationsWeldmentProfiles)
End Sub

If all you want to do is replace any that are currently there, just write a new value. The old value will be overwritten.
 
Otherwise, dig into the registry. Do be careful.
 
rjason71,
Set your options in the swOption.sldreg file. Then have everyone use that file. You will not need the macro at all. However it would be nice.

We used to keep and read our common files of a server. We changed our server 4 times now. Our Visual Basic code was running and reading the files off the server. Every time we got a new server I would rewrite the code. Bad idea.

Now I copy the common files off the server to the local machines. Now when the server changes I change one line of code to point to the new server. E.g. \\myserver\SolidWorks\...

If our server goes down we can still work. If some want to work at home on a laptop, they run the program to copy the files to the C:\ drive.

I like handleman way of changing the locations. But I would suggest not pointing to a mapped drive.


Bradley
SolidWorks Premim 2007 x64 SP3.1
PDM Works, Intel(R) Pentium(R) D CPU
3.00 GHz, 4 GB RAM, Virtual memory 12577 MB, nVidia 3400
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top