How do I get the name of the icon created by the user?

  • 1
  • Question
  • Updated 10 months ago
  • (Edited)
I use
MindManager 17.2.208 (64x)
OS: Windows 7 Professional 64-bit. Service Pack 1, version 6.1.7601

The user creates icons
   - GROUP-1
        1_ЗН_ГР_1
        2_ЗН_ГР_1
        3_ЗН_ГР_1
   - GROUP-2
        1_ЗН_ГР_2
        2_ЗН_ГР_2
        3_ЗН_ГР_2

I'm trying to extract the icon's name
'#Language "WWB-COM"
Option Explicit
Dim tpcWorking As Topic
Dim tpcWorkingTxt As String Dim tpcWrkIcon As Icon
Dim tpcWrkIconTxt As String Sub Main For Each tpcWorking In ActiveDocument.FloatingTopics(True)
tpcWorkingTxt = tpcWorking.Text For Each tpcWrkIcon In tpcWorking.AllIcons
tpcWrkIconTxt = tpcWrkIcon.Name MsgBox "Текст топика - '" & tpcWorkingTxt & "' иконка " & tpcWrkIconTxt Next Next
 
End Sub

I get:
CustomIcon - 33569288
CustomIcon - 135341894

Files - link


How to extract the name of these icons in the form - N_ЗН_ГР_N?
In my case, "1_ЗН_ГР_1" and "2_ЗН_ГР_2".




Photo of Ivan

Ivan

  • 41 Posts
  • 0 Reply Likes

Posted 10 months ago

  • 1
Photo of Nick Duffill

Nick Duffill, Champion

  • 508 Posts
  • 169 Reply Likes
The icon name is not stored in the topic, but is in the Map Markers collection for that map. So for each icon on a topic, you will need to find it in the Map Markers collection to extract the name. Unfortunately the data on each topic does not include a pointer or GIUD for a unique marker, so a search of the Map Markers collection is needed to match on the stock icon or custom icon signature. Note that the marker pointers returned in the Map Marker collection are dynamic and can change if the markers collection changes later.
Photo of Ivan

Ivan

  • 41 Posts
  • 0 Reply Likes
Unfortunately I'm just starting to understand macros.

If it's not difficult for you, could you tell me how to write a macro to solve my question.

Or at least what commands to use.

Thank you
Photo of Nick Duffill

Nick Duffill, Champion

  • 508 Posts
  • 169 Reply Likes
This code will find icons that are Stock Icons by matching the stock icon enumeration. You will need a different routine for finding the names of Custom icons by matching the custom icon signature. It assumes that stock icons are only defined once in the map marker collection.
'#Language "WWB-COM"

Option Explicit

Sub Main
    Dim m_Icon As Icon
    Debug.Clear

    With ActiveDocument.Selection.PrimaryTopic
        For Each m_Icon In .Icons
            If m_Icon.Type = mmIconTypeStock Then
                Debug.Print(FindStockIconName(ActiveDocument, m_Icon.StockIcon))
            End If
        Next
    End With

End Sub

Function FindStockIconName(ByVal m_Doc As Document, ByVal e_StockIcon As MmStockIcon) As String
    Dim m_Group As MapMarkerGroup
    Dim m_Marker As MapMarker

    FindStockIconName = "?"
    For Each m_Group In m_Doc.MapMarkerGroups
        Select Case m_Group.Type
            Case mmMapMarkerGroupTypeSingleIcon, mmMapMarkerGroupTypeIcon
            For Each m_Marker In m_Group
                If m_Marker.Icon.StockIcon = e_StockIcon Then
                    FindStockIconName = m_Marker.Label
                    Exit Function
                End If
            Next
        End Select
    Next
End Function

(Edited)