Author Topic: Defining Auto Naming and Counting within the MDG  (Read 11080 times)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Defining Auto Naming and Counting within the M
« Reply #15 on: July 03, 2014, 08:36:03 am »
It definitely won't hurt :-) Me is not the power VB user (anymore) but others certainly are.

q.

ZuluTen

  • EA User
  • **
  • Posts: 56
  • Karma: +0/-0
    • View Profile
Re: Defining Auto Naming and Counting within the M
« Reply #16 on: July 07, 2014, 06:26:14 pm »
In case this can be of use to anyone, this is what I did.

The input is a pair of arrays:
1) Containing the Diagram_ID of every diagram in which the 'Object of Interest' appears. i.e. in which the Reviewer Comment should appear.

2) Containing the Diagram_ID of every diagram in which the Reviewer Comment associated with the 'Object of Interest' currently appears.

Obviously the Reviewer Comment should only appear once in any diagram, hence the tests which appear surrounding the insert command.

Code: [Select]
                       

MatchFound = False 'a status indicator that will be asserted when a match is found
For abacus = 1 to UBound(aryTargetAppearsInID) 'the array holding the list of diagramIDs in which the Flag should appear
      For abacus2 = 1 to UBound(aryFlagAppearsInID) ' 'the array holding the list of diagramIDs in which the Flag currently appears
            If aryTargetAppearsInID(abacus) = aryFlagAppearsInID(abacus2) Then 'the Flag already appears in that diagram
                  MatchFound = true 'assert the status indicator
            end if
      Next 'consider the next diagram in the list
                              
      If MatchFound = False Then 'it wasn't found anywhere, so add the Flag to the Diagram
            'For debugging purposes:
            Session.Output("Add It: ElementID " & intSourceID & " should be added to diagram with ID of " & aryTargetAppearsInID(abacus))
                                    
            'Define a default position where the Flag will be added:
            strAttrib = "Left = 300; Right = 400; Top = -400; Bottom = -470;"
                                    
            Dim objNewElementinDiagram as EA.DiagramObject 'declare the new object
            Dim objTargetDiagram as EA.Diagram 'declare the Diagram
            tempLong = (CLng(aryTargetAppearsInID(abacus))) 'retrieve the destination Diagram's ID from the array and ensure it's  Long
            set objTargetDiagram = Repository.GetDiagramByID(tempLong) 'open that Diagram
            set objNewElementinDiagram = objTargetDiagram.DiagramObjects.AddNew(strAttrib,"") 'Add the extra object
            objNewElementinDiagram.ElementID = CLng(intSourceID) 'Define the source ID of the object - also Long
            objNewElementinDiagram.Update() 'Update the Diagram
      End If
Next