Products

Home Forums eaDocX queries Sorting options for a diagram content

Home Forums eaDocX queries Sorting options for a diagram content

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8400
    Guillaume Finance
    Participant

    Hi,

    I’m trying to generate details of classes displayed in a diagram in Word.
    Having enabled “Diagram and all contents” option, I noticed that the order appears somehow random. Is there any option to sort at least elements by name? Since I can have elements from various packages, it cannot use the tree position values.

    Note that I’m testing the scripting profile so it would be ideal to receive the list of GUIDS where elements have already been sorted alphabetically.

    I noticed a few minor bugs:
    – typo on the menu Insert > Section > Curent Selection (missing an r)
    – when I change the associated script in a profile, it doesn’t save properly (I have to run it several times and close the doc to eventually update ok).

    #8401
    Guillaume Finance
    Participant

    Note that I tried to sort elements from the array of guids received.
    I have a Sort Dictionary VB function that worked well for other scripts, yet it generates an error message.

    Here is an extract of my script :

    [code]
    !INC Local Scripts.EAConstants-VBScriptsub SortDictionary (objDict)
    ‘ constants
    Const dictKey = 1
    Const dictItem = 2
    ‘ variables
    Dim strDict()
    Dim objKey
    Dim strKey,strItem
    Dim X,Y,Z
    ‘ get the dictionary count
    Z = objDict.Count
    ‘ sorting needs more than one item
    If Z > 1 Then
    ‘ create an array to store dictionary information
    ReDim strDict(Z,2)
    X = 0
    ‘ populate the string array
    For Each objKey In objDict
    strDict(X,dictKey) = CStr(objKey)
    strDict(X,dictItem) = CStr(objDict(objKey))
    X = X + 1
    Next
    ‘ perform a a shell sort of the string array
    For X = 0 To (Z – 2)
    For Y = X To (Z – 1)
    If StrComp(strDict(X,1),strDict(Y,1),vbTextCompare) > 0 Then
    strKey = strDict(X,dictKey)
    strItem = strDict(X,dictItem)
    strDict(X,dictKey) = strDict(Y,dictKey)
    strDict(X,dictItem) = strDict(Y,dictItem)
    strDict(Y,dictKey) = strKey
    strDict(Y,dictItem) = strItem
    End If
    Next
    Next
    ‘ erase the contents of the dictionary object
    objDict.RemoveAll
    ‘ repopulate the dictionary with the sorted information
    For X = 0 To (Z – 1)
    objDict.Add strDict(X,dictKey), strDict(X,dictItem)
    Next
    end if
    end sub

    function exporteaDocX
    ELEMGUIDS = ElementGuid.ToString()
    ‘slit them up into individual GUIDs for processing below
    Guids = Split(ELEMGUIDS , “,”)
    dim diagElements
    set diagElements = CreateObject( “Scripting.Dictionary” )
    dim theElement as EA.Element
    dim theAttribute as EA.Attribute

    For i = LBound(Guids) to UBound(Guids) ‘ do this for each GUID in the list
    set theElement = Repository.GetElementByGuid(Guids(i))
    diagElements.Add theElement.Name, theElement.ElementGUID
    next
    SortDictionary diagElements
    dim outputHTML…
    [/code]

    #8402
    Guillaume Finance
    Participant

    I’m happy to report that I found a solution and got my script to work.
    I need to carry additional tests and will share results once possible.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Compare licence prices

Choose the licence that’s right for you and your team

Prices

Download a free trial

Download eaTeamWorks today for several free for life features, plus no obligation, 30-day trials of all the products: eaDocX, ea Revision Manager, eaSheets, Model Expert and PortfolioManager. Discover for yourself why we sell the world’s best-selling Enterprise Architect extension.

Download