You can access the current workspace using the ActiveWorkspace global property, open, save, and close workspaces, and add folders and documents to it.
The following script constructs a simple folder structure in a workspace and adds and creates several models in it:
Option Explicit ' Close existing workspace and save it to Temp Dim workspace, curentFolder Set workspace = ActiveWorkspace workspace.Load "%_EXAMPLES%\mywsp.sws" Output "Saving current workspace to ""Example directory : "+EvaluateNamedPath("%_EXAMPLES%\temp.sws") workspace.Save "%_EXAMPLES%\Temp.SWS" workspace.Close workspace.Name = "VBS WSP" workspace.FileName = "VBSWSP.SWS" workspace.Load "%_EXAMPLES%\Temp.SWS" dim Item, subitem for each Item in workspace.children If item.IsKindOf(PdWsp.cls_WorkspaceFolder) Then ShowFolder (item) renameFolder item,"FolderToRename", "RenamedFolder" deleteFolder item,"FolderToDelete" curentFolder = item ElsIf item.IsKindOf(PdWsp.cls_WorkspaceModel) Then ElsIf item.IsKindOf(PdWsp.cls_WorkspaceFile) Then End if next Dim subfolder 'insert folder in root Set subfolder = workspace.Children.CreateNew(PdWsp.cls_WorkspaceFolder) subfolder.name = "Newfolder(VBS)" 'insert folder in root at pos 6 Set subfolder = workspace.Children.CreateNewAt(5, PdWsp.cls_WorkspaceFolder) subfolder.name = "Newfolder(VBS)insertedAtPos5"' ' add a new folder in this folder Set subfolder = subfolder.Children.CreateNew(PdWsp.cls_WorkspaceFolder) subfolder.name = "NewSubFolder(VBS)" subfolder.AddDocument EvaluateNamedPath("%_EXAMPLES%\pdmrep.rtf") subfolder.AddDocument EvaluateNamedPath("%_EXAMPLES%\cdmrep.rtf") subfolder.AddDocument EvaluateNamedPath("%_EXAMPLES%\project.pdm") subfolder.AddDocument EvaluateNamedPath("%_EXAMPLES%\demo.oom") dim lastmodel set lastmodel = subfolder.AddDocument (EvaluateNamedPath("%_EXAMPLES%\Ordinateurs.fem")) lastmodel.open lastmodel.name = "Computers" lastmodel.close 'detaching model from workspace lastmodel.delete workspace.Save "%_EXAMPLES%\Final.SWS"
For more information about properties and methods available on the workspace, select and navigate to Libraries/PdWSP/Workspace.