Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Changing Default Settings

Status
Not open for further replies.

Creigbm

Mechanical
Aug 1, 2003
161
Before upgrading to SW2005, I am creating a 'batch update' macro that will load all of the default templates using the following code:

Code:
Dim swApp       As Object
Dim Part        As Object
Dim retval      As Integer

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

swApp.SetUserPreferenceStringValue swDefaultTemplateAssembly, "H:\SolidWorks\Standard Templates\Radial Assembly.asmdot"
swApp.SetUserPreferenceStringValue swDefaultTemplateDrawing, "H:\SolidWorks\Standard Templates\Drawing.drwdot"
swApp.SetUserPreferenceStringValue swDefaultTemplatePart, "H:\SolidWorks\Standard Templates\Radial Part.prtdot"
swApp.SetUserPreferenceStringValue swFileLocationsDocumentTemplates, "H:\SolidWorks\Standard Templates"
swApp.SetUserPreferenceStringValue swFileLocationsDocumentTemplates, "H:\SolidWorks\Skin Templates"
swApp.SetUserPreferenceStringValue swFileLocationsBOMTemplates, "H:\SolidWorks\BOM"
swApp.SetUserPreferenceStringValue swFileLocationsMacros, "H:\SolidWorks\Macros"

retval = MsgBox("Settings Update Complete ", vbExclamation, "Settings Wizard")

End Sub

It works great with one exception. The line that adds the swFileLocationsDocumentTemplates only adds the second folder, not the first as well. Is this a limitation that you cannot add multiple folders of templates using the SW API? I have tried doing something like "H:/fdsfs" & "H:/fsdf" and that doesnt work either.
 
Replies continue below

Recommended for you

You might try to add both with the same call. It looks like you are setting it to Standard templates, and then setting it to Skin Templates after words, one is replacing the other. If you put a ' in front of the second one it will set the first one only.

Try doing both with a single command, sorta like swfilelocatoinsdocumenttemplates, "blablabla" _
"blablablablabla"


 
aamoroso,

Just tried that and had no luck. I am coming to think that it is simply a limitation; a stupid one but hey, I guess that is was upgrades are for.
 
Could it be the same call, with strings and separator?

Example: "H:/fdsfs"; "H:/fsdf" or "H:/fdsfs", "H:/fsdf"

This macro is a good idea!

Good Luck
 
macPT,

Tried both, no luck still. I contacted our VAR and they are looking into it as well...good brain teaser for an election day!
 
I've always applied these settings with a registry file. You can call the reg file from the vb code.

As for a possible solution, it appears that the second entry is overwriting the first. Try entering the two locations as one string separated by a space, comma or semi colon (Not sure about the proper syntax). It's stored in the registry as just one string for that entry.

Jason Capriotti
Smith & Nephew, Inc.
 
Gildashard,

How do you normally write the registry file? What is the deliminater between the two files? I have tried a combination of strings as well as a combination of file locations within one string. Thanks for everyones help.
 
All,

Got it to work. I used Gildashard's idea with creating one string as follows:

"H:/asdf/asdf;H:/qwe/qwe"

When I wrote my last post I had this:

"H:/asdf/asdf ; H:/qwe/qwe"

I guess the spaces make a difference! Thanks again for eveyones help.
 
I export the reg file using the registry(regedit), tweak and then import it on each users computer with a batch files.

Jason Capriotti
Smith & Nephew, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor