Get and Set Search Folders Example (VB.NET)
This example shows how to get and set the file locations in which SolidWorks
searches for reference documents.
'----------------------------------------------------------------------------
' Preconditions: Open SolidWorks.
'
' Postconditions:
' 1. Inspect the Immediate window.
' 2. c:\ is added to the beginning of the search folder path for
reference
' documents.
'
---------------------------------------------------------------------------
Imports
SolidWorks.Interop.sldworks
Imports
SolidWorks.Interop.swconst
Imports
System.Runtime.InteropServices
Imports
System
Imports
System.Diagnostics
Partial
Class
SolidWorksMacro
Dim
Part As
ModelDoc2
Dim
searchFolders As
String
Dim
boolstatus As
Boolean
Sub
main()
Part = swApp.ActiveDoc
swApp.SetUserPreferenceToggle(swUserPreferenceToggle_e.swUseFolderSearchRules,
False)
searchFolders = "c:\;"
& searchFolders
boolstatus = swApp.SetSearchFolders(0, searchFolders)
searchFolders = swApp.GetSearchFolders(0)
Debug.Print("New search path:
" & searchFolders)
End
Sub
Public
swApp As
SldWorks
End
Class