' Relocate Associations Script ' ' (c) 2000 by Michael Moors ' ' Author: Michael Moors ' Date: 12 January 2000 ' ' Description: ' This script reports links that are not assigned to an association. ' Sub Main dim cats as CategoryCollection set cats = RoseApp.CurrentModel.GetAllCategories ' ' Get all scenario diagrams in the model ' dim diags as new scenarioDiagramCollection dim t as ScenarioDiagramCollection for i% = 1 to cats.count set t = cats.getat(i).ScenarioDiagrams for j% = 1 to t.count diags.Add t.Getat(j) next j next i ' ' Extract all scenario diagrams from use cases ' dim ucases as UseCaseCollection set ucases = RoseApp.CurrentModel.GetAllUseCases for i% = 1 to ucases.count set t = ucases.getat(i).ScenarioDiagrams for j% = 1 to t.count diags.Add t.Getat(j) next j next i ' ' Extract all the links in all the scenario diagrams in the model ' Dim linkColl As New LinkCollection Dim mc As InstanceViewCollection for i = 1 to diags.count Set mc = diags.getat(i).instanceviews For j = 1 To mc.count linkColl.addcollection mc.getat(j).getinstance.links next j next i ' ' Remove duplicates ' For i = 1 To linkcoll.count For j = 1 To linkcoll.count If i <> j Then If linkcoll.getat(i) Is linkcoll.getat(j) Then linkcoll.remove linkcoll.getat(j) End If End If Next j Next i ' check for duplicates For i = 1 To linkcoll.count For j = 1 To linkcoll.count If j <> i Then If linkcoll.getat(j) Is linkcoll.getat(i) Then msgbox "Duplicate found!!!" End If End If Next j Next i viewport.open viewport.clear Print "=================================================================" Print "Report of all links that don't have a reference to an association" Print "=================================================================" ' ' Loop through the links and report the ones without assigned association ' Dim assoc As Association Dim total As Long total = 0 For i = 1 To linkcoll.count Set assoc = linkcoll.getat(i).getassociation If assoc Is Nothing Then total = total + 1 Print linkcoll.getat(i).getqualifiedname End If Next i Print "=================================================================" Print "Total number of links without a reference to an association: " & Total Print "=================================================================" End Sub