[CE} Creating A Workset with a "seed" dgn file in the dgn folder.

Is there a way to create a seed Workset that contains a seed DGN file in the DGN Folder?

I see that I can create a Workset and then use it as a template, but I'd like to not allow users to select that template as the active workset, but only as a template. Is that possible? 

  • This isn't possible that I know of. It seems that Bentley doesn't have a variable to control where Template WorkSets are found. I wrote a VBS that allows this though. I have attached it, I use 3 fixed location; 

    'This is the location it puts the cfg's for the application to find,
    'the application must be configured to read them at this location
    worksetCfgDir = "M:\WorkSets"
    'This is the location it will find the seed WorkSets located,
    'both a CFG and parent folder need to be located here.
    wsSeedRoots = "M:\Organization\CivilWorksetSeed"
    'This is the location it will output the Project to
    projLocation = "c:\temp"

    Option Explicit
    
    DIM fso
    Dim sh
    DIM wsSeedDir
    Dim wsSeedRoot
    Dim wsSeedFile
    Dim wsSeedDGNws
    DIM prjNum
    Dim prjCfgFile
    Dim projLocation
    Dim newText
    Dim objFile
    Dim strText
    Dim compText
    Dim prjPath
    Dim prjRootPath
    Dim existsCopyFile
    Dim msg
    Dim title
    Dim strPrompt
    Dim intOptions
    Dim wsSeedRoots
    Dim rv
    Dim prjDestFolder
    Dim worksetCfgDir
    Dim rem1
    Dim rem2
    Dim rem3
    Dim iNumberOfLinesToDelete
    Dim arrLines
    Dim i
    
    Const ForReading = 1
    Const ForWriting = 2
    Const ForAppending = 8
    Const WINDOW_HANDLE = 0
    Const BIF_EDITBOX = &H10
    Const BIF_NONEWFOLDER = &H0200
    Const BIF_RETURNONLYFSDIRS = &H1
        
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set sh = CreateObject("Shell.Application")
    
    strPrompt = "Where is your project stored?"
    intOptions =  BIF_RETURNONLYFSDIRS + BIF_EDITBOX + BIF_NONEWFOLDER
    rem1 = "#======================================================================"
    rem3 = "# Set the WorkSet root folder"
    iNumberOfLinesToDelete = 4
    
    'This is the location it puts the cfg's for the application to find,
    'the application must be configured to read them at this location
    worksetCfgDir = "M:\Configuration\WorkSets"
    
    'This is the location it will find the seed WorkSets located,
    'both a CFG and parent folder need to be located here.
    wsSeedRoots = "M:\Configuration\Organization\CivilWorksetSeed"
    
    'This is the location it will output the Project to
    projLocation = "c:\temp"
    		
    Set rv = sh.BrowseForFolder(WINDOW_HANDLE, strPrompt, intOptions, projLocation)
    		
    If rv Is Nothing Then
    	WScript.Quit
    Else
    	prjRootPath = (rv.Self.Path)
    End If
    
    prjNum = "false"
    
    Do while prjNum = "false"
    	prjNum = InputBox("Enter the project:","Project number","1234" )
    	prjDestFolder = (prjRootPath & "\" & prjNum)
    	prjCfgFile = (worksetCfgDir & "\" & prjNum & ".cfg")
    	If IsEmpty (prjNum) Then
    		WScript.Quit
    	ElseIf fso.FolderExists(prjDestFolder) Then
    		msg = "Project directory " & prjDestFolder & " already exists."
    			If fso.FileExists (prjCfgFile) Then
    				msg = msg & vbCrLf & "Project file " & prjCfgFile & " already exists."
    				title = "Working"
    			End If
    		MsgBox msg, 0, title
    		prjNum = "false"
    	ElseIf fso.FileExists (prjCfgFile) Then
    		msg = "Project file " & prjCfgFile & " already exists."
    		title = "Working"
    		MsgBox msg, 0, title
    		prjNum = "false"
    	End If
    Loop
    
    rv =  null
    Set rv = sh.BrowseForFolder(WINDOW_HANDLE, strPrompt, intOptions, wsSeedRoots)
    		
    If rv Is Nothing Then
    	WScript.Quit
    Else
    	wsSeedDir = (rv.Self.Path)
    End If
    
    wsSeedFile = wsSeedRoots & "\" & "Seed.cfg"
    wsSeedDGNws = wsSeedRoots & "\" & "Seed.DGNws"
    
    fso.CopyFolder wsSeedDir, prjDestFolder
    If fso.FolderExists (prjDestFolder) Then
    	msg = "Project directory created " & prjDestFolder
    	fso.CopyFile wsSeedDGNws, prjDestFolder & "\" & prjNum &".DGNws"
    	If fso.FileExists (prjDestFolder & "\" & prjNum &".DGNws") Then
    		msg = msg & vbCrLf & "DGNws file " & prjDestFolder & "\" & prjNum &".DGNws" & " was created!"
    	End If
    End If
    
    Set objFile = FSO.OpenTextFile(wsSeedFile, ForReading)	
    	strText = objFile.ReadAll
    	objFile.Close
    
    arrLines = Split(strText, vbNewLine)
    rem2 = "# Configuration file " & prjNum & ".cfg"
    newText = ("_USTN_WORKSETROOT 	= " & prjRootPath & "$(_USTN_WORKSETNAME)/")
    
    Set objFile = fso.CreateTextFile(prjCfgFile, ForWriting, True)
    	compText = Replace (rem1 & vbCrLf & rem2 & vbCrLf & rem3 & vbCrLf & rem1 & vbCrLf & newText & vbCrLf,"\", "/")
    	objFile.WriteLine compText
    	For i=0 To UBound(arrLines) 
    	   If i > (iNumberOfLinesToDelete - 1) Then 
    	      objFile.WriteLine arrLines(i) 
    	   End If 
    	Next
    	objFile.Close
    
    If fso.FileExists (prjCfgFile) Then 
    		msg = msg & vbCrLf & "Project file created " & prjCfgFile
    End If
    
    msg = msg & vbCrLf & vbCrLf & "Your Project " & prjNum & " was created successfully! "
    title = "Worked"
    MsgBox msg, 0, title
    WScript.Quit

    ~HTH

    John.

    yep