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

Draw a line

Hello

I need to draw a line between 2 coordinates and have found the code I think I need in the help files which is below. However I'm getting the error Type identifier is invalid for the statement Dim mcgoCreated As McGraphObj. I've added the references for IQL.Features and I've imported  IQL.Features in the script. I also imported IQL.Display and Addins.Overlays but they didn't help either, any help appreciated.

Sub DrawLine

        Dim mcgoCreated As McGraphObj

         With ActiveImage.LineFeatures
            .AutoDisplay = True 'True by default for McImage.LineFeatures
            .Reset 'empty it, to be sure

            '*** for feature 0 create a McGraphObjLine
            Set mcgoCreated = .AutoDisplayOverlay.Add("McGraphObjLine", mcgtStandardAutoDisplay)
            mcgoCreated.SetHandle 1, 10, 20
            mcgoCreated.SetHandle 2, 30, 20
            'The McGraphObj Templates for AutoDisplayOverlay are all non-visible by default
            mcgoCreated.Style(mcgsVisible) = mcgsVisible 'make it visible
        End With
    End Sub

Regards

Dave

Best Answer

  • Answer ✓
    Hi David,

    There is AnnotationOverlay image property, that should be used for drawing annotaiton objects. The macro below creates a line in annotation overlay:

        'Draw line in annotation overlay using low level IQL function
        Public Sub DrawLineIQL
            Dim im As McImage=ThisApplication.ActiveImage
            If im Is Nothing Then Exit Sub' no image
            Dim ovl As MediaCy.IQL.Display.Overlays.McGraphOverlay=im.AnnotationOverlay
            Dim line As MediaCy.IQL.Display.Overlays.McGraphObjLine=ovl.Add("McGraphObjLine")
            line.SetHandle(1,100,100)
            line.SetHandle(2,200,300)
            line.NotifyCreationComplete
        End Sub

    I have attached a project (with all references) that implements it. The project also contains RecordedDrawLineMacro macro that shows another way of drawing lines using recorded commands.

    Regards,

    Yuri

Answers

  • Hello Yuri,

    Thanks, the low level IQL version is exactly what I want.

    Regards

    Dave

Sign In or Register to comment.