Home Image-Pro Automation (Macros, Apps, Reports)

CHANGE ANNOTATION TEXT OBJECT BASED ON TEXT STRING VALUE . . .

2020-08-21-183542

All --

I have a large set of IMAGE-PRO TIF IMAGE FILES.

There are ANNOTATION OBJECTS present in / on the TIF IMAGES.

The CODE below will allow me to change the TEXT in the ANNOTATION TEXT OBJECT from what it was to "FRED".

If I want to append "FRED" to the old TEXT in the ANNOTATION TEXT OBJECT or I want to change the TEXT to "FRED" only if it is "WILMA", how do I get the value for the TEXT within an ANNOTATION TEXT OBJECT.

For this set of images, I believe that there will be only one ANNOTATION TEXT OBJECT on the IMAGE but if there is a way to query the image for the number of ANNOTATION TEXT OBJECTS and loop through them so that all of the TEXT STRINGS are examined and updated, that would be super.

Thanks in advance.

-- Matt

    Public Function NewMacro() As SimpleScript
        NewMacro = New SimpleScript
        Dim image1, doc1

        With Application.DocumentCommands.ActiveImage(NewMacro)
            .Run(image1)
        End With

        With [Select].AnnotationsCommands.SelectObject(NewMacro)
            .Overlay = Overlays.OverlayType.AnnotationsOverlay
            .GraphicObject = 6
            .Selected = False
            .Run(image1)
        End With

        With [Select].AnnotationsCommands.SelectObject(NewMacro)
            .Overlay = Overlays.OverlayType.AnnotationsOverlay
            .GraphicObject = 1
            .Selected = True
            .Run(image1)
        End With

        With Application.Gadgets.DisplayOptions(NewMacro)
            .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
            .Run()
        End With

        With Application.DocumentCommands.Define(NewMacro)
            .Run(image1, doc1)
        End With

        With [Select].Annotations.ShapeCommands.Text(NewMacro)
            .Overlay = Overlays.OverlayType.AnnotationsOverlay
            .ApplyTo = Overlays.ShapeAction.SelectedGraphicObject
            .Text = "FRED"
            .Run(doc1)
        End With

        With [Select].AnnotationsCommands.SelectObject(NewMacro)
            .Overlay = Overlays.OverlayType.AnnotationsOverlay
            .GraphicObject = 1
            .Selected = False
            .Run(image1)
        End With

    End Function


Answers

  • A text annotation will be an object of type MediaCy.IQL.Display.Overlay.McGraphObjText.  You can look it up in the Automation Help to see all of the properties that can be set (font, text size, etcetera).  But the property you want is the McGraphObjText.Text property.  If the text you are interested in is a label, then the McGraphObj.Label property will expose this.  If it is not Nothing, then you can assign to the McGraphObj.Label.Text property to set the Label text.
  • edited August 2020
    Hi Matt,

    As Craig mentioned, you should use low level overlay functions. Here is a sample macro that can be used as a starter.  Note that your project must have a reference to MediaCy.IQL.Display and "Imports MediaCy.IQL.Display.Overlays"

    Imports MediaCy.IQL.Display.Overlays
    ...
        Public Sub PrintAnnotationText
            Dim ovr As MediaCy.IQL.Display.Overlays.McGraphOverlay=ThisApplication.ActiveImage.AnnotationOverlay
            For Each grObj As McGraphObj In ovr 'loop through all objects in annotation overlay
                If grObj IsNot Nothing AndAlso grObj.ClassName="McGraphObjText" Then 'find Text object
                    Dim textObj As McGraphObjText=grObj
                    Debug.Print(textObj.Text)'print text
                End If
            Next
        End Sub
    

    Yuri
  • edited August 2020
    2020-08-24-095612

    Craig and Yuri --

    Thank you very much for your guidance.

    I will try to weave your suggestions into CODE that does what this IMAGE-PRO USER needs.  They have hundreds of images that were annotated incorrectly that need to be modified in a standardized way.  Doing this by hand would take hours.  Doing this by CODE will take minutes if I can make the CODE work properly. 

    Thanks again.

    -- Matt

Sign In or Register to comment.