Copy files on workset creation

Hi

I think I've seen this question somewhere before, but I can't find it now (looked everywhere):

In my configuration, I want to separate our workset folder from our .dgnws and .cfg. The reason is on our server P:/ we store all our projects and we want them to be stored right in that folder, not under a workspace folder, nor do we want those configuration-files to clutter that folder. I've manage to set that up, so on R:/ we have workspaces (both it's folders, and it's cfg-files) and the worksets cfg and dgnws-files. And on P:/ we have the workset's folder with both models and workset-standards-folder. 

Now to the problem. With this set up the files and folders don't get copied from the template workset, to my P:/ location (or to the R: either for that matter). We've got to manually copy a folder, which not all users have accepted. 

Last time I saw this problem somewhere, I think one Bentley-employee answered this was a known problem, but this would get fixed. What's the status of this? 

Regards, 

Robert. 

  • Hi Robert, I think it was me. We have made some fixes in this area but I'm not confident that we have resolved this yet. I was testing this exact function a few days ago and encountered the same behaviour. I'll let you know what develops over the next coupe of weeks.

    For the moment when the (entirely logical!) split you describe is implemented manual creation of the missing WorkSet folders is the best solution.

    I was testing this a few days ago (I've been away) so will report back on anything new that I find or we progress with.

    Regards

    Marc

  • The templating of WorkSets just doesn't work right. It may have gotten better with u13 but I haven't had time to test it.

    I wrote a VBS file to do what you want. Give it a try if you like.

    YOu will need to define 2 thing (where it puts the CFG for Bentley's application to read, and where it finds the seed worksets);

    '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:\PennDOT_CE_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:\PennDOT_CE_Configuration\Organization\CivilWorksetSeed"
    Note that I place the dgnws inside the folder that is where my project will be stored. You would need to write the code to place it in a different location.

    Option Explicit
    
    DIM fso
    Dim sh
    DIM wsSeedDir
    Dim wsSeedRoot
    Dim wsSeedFile
    Dim wsSeedDGNws
    DIM prjNum
    Dim prjCfgFile
    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:\PennDOT_CE_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:\PennDOT_CE_Configuration\Organization\CivilWorksetSeed"
    		
    Set rv = sh.BrowseForFolder(WINDOW_HANDLE, strPrompt, intOptions)
    		
    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
    
    strPrompt = "What is your seed Project?"
    intOptions =  BIF_RETURNONLYFSDIRS + BIF_EDITBOX + BIF_NONEWFOLDER
    
    rv = False
    Do While rv = False
    	Set rv = sh.BrowseForFolder(WINDOW_HANDLE, strPrompt, intOptions, wsSeedRoots)
    	If rv Is Nothing Then
    		WScript.Quit
    	ElseIf StrComp (rv.self.path, wsSeedRoot, 1) = 0 Then
    		msg = "You must choose a sub directory!" & vbCrLf & rv.self.path & vbCrLf & wsSeedRoot
    		title = "Worked"
    		MsgBox msg, 0, title
    		rv = False
    	ElseIf Not fso.FileExists (rv.self.path & ".cfg") Then
    		msg = "Seed configuration file " & rv.self.path & ".cfg" & " does not exist."
    		title = "Error"
    		MsgBox msg, 0, title
    		rv = False
    	ElseIf Not fso.FileExists (rv.self.path & "\" & rv & ".dgnws") Then
    		msg = "Seed DGNws file " & rv.self.path & "\" & rv & ".dgnws" & " does not exist. Contact CADD support!"
    		title = "Error"
    		MsgBox msg, 0, title
    		rv = False
    	Else
    		wsSeedDir = (rv.Self.Path)
    		wsSeedFile = (rv & ".cfg")
    		wsSeedDGNws = (rv & ".DGNws")
    	End If
    Loop
    
    fso.CopyFolder wsSeedDir, prjDestFolder
    If fso.FolderExists (prjDestFolder) Then
    	msg = "Project directory created " & prjDestFolder
    	fso.MoveFile prjDestFolder & "\" & 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(wsSeedDir & ".cfg", 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,

    ~HTH

    John.

    yep