×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Changing Default Settings

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:

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.

RE: Changing Default Settings

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"


RE: Changing Default Settings

(OP)
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.

RE: Changing Default Settings

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

RE: Changing Default Settings

(OP)
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!

RE: Changing Default Settings

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.

RE: Changing Default Settings

(OP)
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.

RE: Changing Default Settings

(OP)
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.

RE: Changing Default Settings

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources