Chapter 8 Manipulating The Workspace Using Scripts
You can also manipulate the content of a workspace using the following items:
You can use the AddDocument(ByVal filename As String, ByVal position As Long = -1) As BaseObject method on the WorkspaceFolder to add documents to the workspace.
Example of a workspace manipulation:
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"
Copyright (C) 2006. Sybase Inc. All rights reserved. |
![]() |