Changing Default Settings
Changing Default Settings
(OP)
Before upgrading to SW2005, I am creating a 'batch update' macro that will load all of the default templates using the following code:
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.
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
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.






RE: Changing Default Settings
Try doing both with a single command, sorta like swfilelocatoinsdocumenttemplates, "blablabla" _
"blablablablabla"
RE: Changing Default Settings
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.
RE: Changing Default Settings
Example: "H:/fdsfs"; "H:/fsdf" or "H:/fdsfs", "H:/fsdf"
This macro is a good idea!
Good Luck
RE: Changing Default Settings
Tried both, no luck still. I contacted our VAR and they are looking into it as well...good brain teaser for an election day!
RE: Changing Default Settings
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.
RE: Changing Default Settings
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.
RE: Changing Default Settings
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.
RE: Changing Default Settings
Jason Capriotti
Smith & Nephew, Inc.