Sub Main Const Debug As Boolean = False If Debug Then viewport.open If Debug Then viewport.clear Dim theActiveDiagram As Diagram Set theActiveDiagram = RoseApp.CurrentModel.GetActiveDiagram Dim allCategories As CategoryCollection Set allCategories = RoseApp.CurrentModel.GetAllCategories Dim allUseCases As UseCaseCollection Set allUseCases = RoseApp.CurrentModel.GetAllUseCases Dim theSelectedUseCases As UseCaseCollection Set theSelectedUseCases = RoseApp.CurrentModel.GetSelectedUseCases Dim theScenarioDiagrams As ScenarioDiagramCollection Dim theScenarioDiagram As ScenarioDiagram Dim foundScenarioDiagram As Boolean Dim allObjectInstances As ObjectInstanceCollection Dim theObjectInstance As ObjectInstance Dim ClassAdded As Boolean Dim TheClassIsOnDiagram As Boolean Dim theUseCase As UseCase Dim theClasses As ClassCollection Dim theClassDiagram As ClassDiagram Dim theClassDiagrams As ClassDiagramCollection Dim theCurrentClassDiagram As ClassDiagram Dim theCategory As Category Dim theClass As Class Dim theExistingClass As Class foundScenarioDiagram = False If theActiveDiagram Is Not Nothing Then For i% = 1 To allCategories.Count Set theCategory = allCategories.getat (i) Set theScenarioDiagrams = theCategory.ScenarioDiagrams For d% = 1 To theScenarioDiagrams.count Set theScenarioDiagram = theScenarioDiagrams.getat (d) If theScenarioDiagram.GetUniqueId = theActiveDiagram.GetUniqueId Then foundScenarioDiagram = True Set theClassDiagram = theCategory.AddClassDiagram ("VOPC " & theScenarioDiagram.Name) Set allObjectInstances = theScenarioDiagram.GetObjects If Debug Then Print ("Number of ObjectInstances: " & allObjectInstances.count) For o% = 1 To allObjectInstances.count Set theObjectInstance = allObjectInstances.getat (o) Set theClass = theObjectInstance.GetClass If theClass Is Not Nothing Then Set theClasses = theClassDiagram.GetClasses TheClassIsOnDiagram = False For c% = 1 To theClasses.count Set theExistingClass = theClasses.getat (c) If theExistingClass.GetUniqueId = theClass.GetUniqueId Then If Debug Then Print ("The class already is on the diagram") TheClassIsOnDiagram = True Exit For End If Next c If Not TheClassIsOnDiagram Then If Not theClass.Stereotype = "Actor" Then ClassAdded = theClassDiagram.AddClass (theClass) End If End If Next o End If If FoundScenarioDiagram Then Exit For Next d If FoundScenarioDiagram Then Exit For Next i If Not FoundScenarioDiagram Then For i% = 1 To allUseCases.Count Set theUseCase = allUseCases.getat (i) Set theScenarioDiagrams = theUseCase.ScenarioDiagrams For d% = 1 To theScenarioDiagrams.count Set theScenarioDiagram = theScenarioDiagrams.getat (d) If theScenarioDiagram.GetUniqueId = theActiveDiagram.GetUniqueId Then foundScenarioDiagram = True Set theClassDiagram = theUseCase.AddClassDiagram ("VOPC " & theScenarioDiagram.Name) Set allObjectInstances = theScenarioDiagram.GetObjects If Debug Then Print ("Number of ObjectInstances: " & allObjectInstances.count) For o% = 1 To allObjectInstances.count Set theObjectInstance = allObjectInstances.getat (o) Set theClass = theObjectInstance.GetClass If theClass Is Not Nothing Then Set theClasses = theClassDiagram.GetClasses TheClassIsOnDiagram = False For c% = 1 To theClasses.count Set theExistingClass = theClasses.getat (c) If theExistingClass.GetUniqueId = theClass.GetUniqueId Then If Debug Then Print ("The class already is on the diagram") TheClassIsOnDiagram = True Exit For End If Next c If Not TheClassIsOnDiagram Then If Not theClass.Stereotype = "Actor" Then ClassAdded = theClassDiagram.AddClass (theClass) End If End If Next o End If If FoundScenarioDiagram Then Exit For Next d If FoundScenarioDiagram Then Exit For Next i End If If Not FoundScenarioDiagram Then For i% = 1 To theSelectedUseCases.Count Set theUseCase = theSelectedUseCases.getat (i) foundScenarioDiagram = True Set theScenarioDiagrams = theUseCase.ScenarioDiagrams Set theClassDiagram = theUseCase.AddClassDiagram ("VOPC " & theUseCase.Name) For b% = 1 To theScenarioDiagrams.count Set theScenarioDiagram = theScenarioDiagrams.getat (b) Set allObjectInstances = theScenarioDiagram.GetObjects If Debug Then Print ("Number of ObjectInstances: " & allObjectInstances.count) For o% = 1 To allObjectInstances.count Set theObjectInstance = allObjectInstances.getat (o) Set theClass = theObjectInstance.GetClass If theClass Is Not Nothing Then Set theClasses = theClassDiagram.GetClasses TheClassIsOnDiagram = False For c% = 1 To theClasses.count Set theExistingClass = theClasses.getat (c) If theExistingClass.GetUniqueId = theClass.GetUniqueId Then If Debug Then Print ("The class already is on the diagram") TheClassIsOnDiagram = True Exit For End If Next c If Not TheClassIsOnDiagram Then If Not theClass.Stereotype = "Actor" Then ClassAdded = theClassDiagram.AddClass (theClass) End If End If Next o Next b Next i End If If Not FoundScenarioDiagram Then MsgBox "Active Diagram not an Interaction Diagram or no Use Case selected on diagram", ebExclamation, "Build VOPC" End If Else MsgBox "Active Diagram not an Interaction Diagram or no Use Case selected on diagram", ebExclamation, "Build VOPC" End If End Sub