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

Line Profile Tool . . .

All --

After selecting

    MEASURE + CALIPER + LINE PROFILE

PREMIER creates a LINE PROFILE RIBBON and a LINE PROFILE LINE within the IMAGE, and a LINE PROFILE DATA DIALOG BOX.

This is shown in the SCREEN CAPTURE attached and below.

If the LINE PROFILE DATA DIALOG BOX is closed, the LINE PROFILE TOOL is DEACTIVATED.

I am working on a PREMIER APP that uses the LINE PROFILE TOOL but does not need the LINE PROFILE DATA DIALOG BOX so it is just cluttering up the computer screen.

Since there is no MINIMIZE button on this DIALOG BOX, I am asking . . .

Is there a way to to make the LINE PROFILE DATA DIALOG BOX box disappear without turning off the LINE PROFILE TOOL?

Thanks.

-- Matt

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-


Answers

  • edited July 2016
    Hi Matt,

    The quick answer is NO. You cannot close Line Profile panel. But you can:
    1) 'hide' this panel (easy to hide, but this is unexpected for the panel's manager).
    2) create Line Profile engine (you know how to do this) and custom Line Profile ribbon and connect them

    Thanks,
    Nikita.
  • edited July 2016
    Nikita --

    Thank you for your response and your suggestion.

    Unfortunately I am not understanding how to implement your suggestion.

    If you could provide a bit more description or code that performs this PREMIER TWEAK, that would be super.

    Also . . .

    In 9.1.4, the TAGS for the MANUAL PATTERN A EDGES are a TURQUOISE COLOR.

    In 9.2.0, the TAGS for the MANUAL PATTERN A EDGES are a RED COLOR.

    This is shown in the SCREEN CAPTURE below and attached.

    The END USER finds the TURQUOISE COLOR easier to see.

    I have hunted for a OPTION that will make this aspect of 9.2.0 look like 9.1.4 but I have not been successful.

    Is this adjustable from the PREMIER UI or from an AUTOMATION?

    Thanks.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-



  • Hi Matt,

    Sure, I'll post example shortly.

    Regarding the color, the class's color overrides the edge's color. You can change color of the class or set option "Show Class Name on Image" Off:
     

    Thanks,
    Nikita.
  • Nakita --

    Thank you for your suggestion about the SHOW CLASS NAME ON IMAGE option.

    This feature is not on in 9.1.4 so that is not making the EDGE MARKS the TURQUOISE COLOR that the CUSTOMER prefers.

    This is shown in the SCREEN CAPTURE below and attached (left side).

    After a bit more sleuthing I found the MONO INTERPRETATION OPTION was ON in 9.1.4 and OFF in 9.2.0.

    When MONO INTERPRETATION OPTION is ON in 9.2.0, the EDGE MARKS for PATTERN A are displayed using the TURQUOISE COLOR that the customer prefers.

    This is also shown in the SCREEN CAPTURE below and attached (right side).

    !!! MYSTERY SOLVED !!!

    I look forward to your example code to hide the LINE PROFILE DATA DIALOG BOX without shutting down the LINE PROFILE TOOL.

    Thanks again.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-


  • edited July 2016
    Hi Matt,

    I think, I put all together to solve your request (well... advanced stuff...):

    Public Module Macros
    
        Public Function GetLPTab As Object
            With ThisApplication.Ribbon
                For Each tab As Object In .Items
                    If tab IsNot Nothing AndAlso tab.Name = "MyLineProfile" Then
                        Return tab
                    End If
                Next
            End With
    
            Return Nothing
        End Function
    
        Public Sub Disable_LP_Panel
            Dim c As MediaCy.IQL.Application.McCommand
    
            For Each c In ThisApplication.Commands ' disable LP Panel for commands which may open it
                If c.Name.StartsWith("Measure.LineProfile.Tools") Then
                    If Not String.IsNullOrEmpty(c.CommandParameter) Then
                        If c.CommandParameter.ToString.Contains("OpenControl='true'") Then
                            c.CommandParameter = c.CommandParameter.ToString.Replace("OpenControl='true'", "OpenControl='false'")
                        End If
                    End If
                End If
            Next
        End Sub
    
        Public Sub Create_LP_RibbonTab
            Dim tab As Object = GetLPTab
    
            If tab Is Nothing Then
                Disable_LP_Panel
                ThisApplication.Ribbon.LoadCustomUI(ThisApplication, System.IO.File.ReadAllText("c:\MyLP.Ribbon")) 'add tab
                tab = GetLPTab
    
            Else
                tab.Visible = True 'show tab
    
            End If
    
            ThisApplication.Ribbon.SelectedRibbonTabItem = tab 'select tab
        End Sub
    
        Public Sub Update_LP_Engine
            Dim tab As Object = GetLPTab
            Dim lpe As MediaCy.Commands.LineProfile.McLineProfileEngine
    
            If tab IsNot Nothing AndAlso tab.Visible Then
                lpe = MediaCy.Commands.LineProfile.AddIn.LineProfileEngine(ThisApplication.ActiveDocument, True)
    
                For Each gr As Object In tab.Panel.Controls
                    gr.LPEngine = lpe ' update LPE for each group on LP tab
                Next
            End If
        End Sub
    
        Public Sub Remove_LP_RibbonTab
            Dim tab As Object = GetLPTab
    
            If tab IsNot Nothing Then
                For Each gr As Object In tab.Panel.Controls
                    gr.LPEngine = Nothing
                Next
    
                tab.Visible = False ' hide tab
            End If
        End Sub
    
    End Module
    
    MyLP.Ribbon is XML file:
    
    <?xml version="1.0" encoding="utf-8" ?>
    
    <customUI>
      <ribbon>
        <tabs>
          <tab id="MyLineProfile" label="My Line Profile" keytip="L">
            <group tag="MediaCy.Controls.LineProfile.dll#MediaCy.Controls.LineProfile.McRibbonBarTools" label="Tools" />
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    
    
    Basically, you need:
    1) Reference to MediaCy.Commands.LineProfile.dll in your app's project
    2) MyLP.Ribbon - definition of the LP custom tab (add groups you need)
    3) Create_LP_RibbonTab - to show custom LP ribbon tab
    4) Remove_LP_RibbonTab - remove custom LP ribbon tab
    5) Call every time Update_LP_Engine then active document changed or closed to connect LPE to LP custom tab

    Let me know, if this works,
    Nikita.

  • Nikita --

    Thank you for the example code.

    I can tell a LOT of work went into this.

    I'll work to weave it into the application this (THU) PM and let you know the outcome.

    Thanks again.

    -- Matt
  • Nikita --

    I have done my best to implement the code that you have provided.

    The routines are up and running within my PROJECT as shown by



    When I run the

        Create_LP_RibbonTab

    I get the

        My Line Profile

    ribbon that I think your code was meant to generate but I do not seem to be able to use any of your functions to eliminate the

        LINE PROFILE DIALOG BOX.

    In the SCREEN CAPTURES below:

    ** A shows what the "factory" PREMIER does when LINE PROFILE is engaged
    ** B shows the MY LINE PROFILE RIBBON generated by your code
    ** C (Photoshopped) shows what I hoping for

    Am I missing something in the application of the EXAMPLE CODE that you provided?

    Thanks.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-


       
  • edited July 2016
    Matt, try to restart Premier and do not open Line Profile. Check commands in your code for "OpenControl=true" and change to "OpenControl=false" (if any) as well as remove Measure.LineProfile.LineProfile command which opens standard Line Profile.

    One more:
    change line "If c.Name.StartsWith("Measure.LineProfile.Tools") Then" with "If c.Name.StartsWith("Measure.LineProfile") Then" - I missed one command which may open standard Line Profile.

    Nikita.
  • Nikita --

    Will do.

    Will update.

    Thanks.

    -- Matt
  • Nikita --

    I have made my best effort to follow your instructions.

    I did the following:

    ** Restarted Premier
    ** Did not open Line Profile.
    ** Did not find any "OpenControl=true" in my ROUTINE
    ** Changed

        "If c.Name.StartsWith("Measure.LineProfile.Tools") Then"

    to

        "If c.Name.StartsWith("Measure.LineProfile") Then"

    And I modified the routine that calls the LINE PROFILE TOOL but I was not sucessful.

    Below are the four routines that you wrote and a modified version of the routine ( "MyCaliperTool" ) that I wrote to give the user a line through the CENTER of the IMAGE and the MANUAL EDGE TOOL.

    The XML file that you directed me to make is

        MyLP.Ribbon.xml

    and it is sitting in the same folder as the IPP and VB files.

    Can you please direct me how to change the "MyCaliperTool" to take advantage of the customized version of the LINE PROFILE TOOL?

    Thanks again.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

        Public Function GetLPTab As Object
            With ThisApplication.Ribbon
                For Each Tab As Object In .Items
                    If Tab IsNot Nothing AndAlso Tab.Name = "MyLineProfile" Then
                        Return Tab
                    End If
                Next
            End With
    
            Return Nothing
        End Function
    
        Public Sub Disable_LP_Panel
            Dim c As MediaCy.IQL.Application.McCommand
    
            For Each c In ThisApplication.Commands ' disable LP Panel for commands which may open it
                If c.Name.StartsWith("Measure.LineProfile") Then
                    If Not String.IsNullOrEmpty(c.CommandParameter) Then
                        If c.CommandParameter.ToString.Contains("OpenControl='true'") Then
                            c.CommandParameter = c.CommandParameter.ToString.Replace("OpenControl='true'", "OpenControl='false'")
                        End If
                    End If
                End If
            Next
        End Sub
    
        Public Sub Create_LP_RibbonTab
            Dim Tab As Object = GetLPTab
    
            If Tab Is Nothing Then
                Disable_LP_Panel
                ThisApplication.Ribbon.LoadCustomUI(ThisApplication, System.IO.File.ReadAllText(MacroDir & "\MyLP.Ribbon.xml")) 'add tab
                Tab = GetLPTab
    
            Else
                Tab.Visible = True 'show tab
    
            End If
    
            ThisApplication.Ribbon.SelectedRibbonTabItem = Tab 'select tab
        End Sub
    
        Public Sub Update_LP_Engine
            Dim Tab As Object = GetLPTab
            Dim lpe As MediaCy.Commands.LineProfile.McLineProfileEngine
    
            If Tab IsNot Nothing AndAlso Tab.Visible Then
                lpe = MediaCy.Commands.LineProfile.AddIn.LineProfileEngine(ThisApplication.ActiveDocument, True)
    
                For Each gr As Object In Tab.Panel.Controls
                    gr.LPEngine = lpe ' update LPE for each group on LP tab
                Next
            End If
        End Sub
    
        Public Sub Remove_LP_RibbonTab
            Dim Tab As Object = GetLPTab
    
            If Tab IsNot Nothing Then
                For Each gr As Object In Tab.Panel.Controls
                    gr.LPEngine = Nothing
                Next
    
                Tab.Visible = False ' hide tab
            End If
        End Sub
    
        Public Function MyCaliperTool()
    
            'Activate the LINE PROFILE FEATURE
    '        With Measure.LineProfileCommands.LineProfile(Nothing)
    '            .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
    '            .Run()
    '        End With
    
            'Activate the CUSTOMIZED LINE PROFILE FEATURE
            Create_LP_RibbonTab
    
            'Remove any preexisting LINE PROFILES from the image
            With Measure.LineProfile.ProfileCommands.RemoveAll(Nothing)
                .Run(ThisApplication.ActiveDocument)
            End With
    
            '-- Create the XY COORDINATES for the LINE PROFILE LINE
    
            Dim MyX1, MyY1 As Double
            MyX1 = ThisApplication.ActiveImage.Width / 2.
            MyY1 = ThisApplication.ActiveImage.Height / 1.
    
            Dim MyX2, MyY2 As Double
            MyX2 = ThisApplication.ActiveImage.Width / 2.
            MyY2 = ThisApplication.ActiveImage.Height * 0.
    
            'Create a LINE PROFILE LINE
            With Measure.LineProfile.ProfileCommands.Add(Nothing)
                .CreateEngine = True
                .ProfileType = LineProfile.ProfileTypes.Line
                .Points = New System.Collections.Generic.List(Of System.Drawing.PointF)
                .Points.Add(New System.Drawing.PointF(MyX1,MyY1))
                .Points.Add(New System.Drawing.PointF(MyX2,MyY2))
                .Angle = 0R
                .Run(ThisApplication.ActiveDocument)
            End With
    
            'Activate the MANUAL EDGE EDITING TOOL
            With measure.LineProfile.ToolsCommands.Select(Nothing)
                .Tool = LineProfile.mcOverlayTool.mcotManualPatternA
                .Run(ThisApplication.ActiveDocument)
            End With
    
        End Function

  • Hi Matt,

    Nikita may add more details, but the file name should be MyLP.Ribbon (not MyLP.Ribbon.xml) and it should be in Premier program folder (where EXE file is).

    Yuri
  • Yuri --

    The line of code that references this file in my code is:

    ThisApplication.Ribbon.LoadCustomUI(ThisApplication, System.IO.File.ReadAllText(MacroDir & "\MyLP.Ribbon.xml")) 'add tab

    and the function seems to work.

    Is there an advantage to leaving off the XML EXTENSION and putting this file in the same folder as the

        Image-Pro Premier.exe

    file?

    -- Matt
  • Hi Matt,

    XML/Ribbon file could be anywhere with any extension.
    I've provided several functions and 5 steps (last step is very important and look like it is missing from MyCaliperCode). Please, review functions and step and let me know, what is not working?

    Thanks,
    Nikita.
  • Nikita --

    Thank you for your response.

    I modified the MyCaliperTool from
            'Activate the CUSTOMIZED LINE PROFILE FEATURE
            Create_LP_RibbonTab
    to
            'Activate the CUSTOM LINE PROFILE FEATURE
            Create_LP_RibbonTab
            Update_LP_Engine
    and was still not successful in getting PREMIER to activate the LINE PROFILE TOOL without the
    LINE PROFILE DATA TABLE WINDOW appearing.

    I would like to get this FEATURE working for the customer but there are higher priority issues to handle so I went back to addressing these and now our work with the LINE PROFILE TOOL seems to have caused another issue.

    In PREMIER 9.1.4, I get this error



    when I run the SAME PROJECT in 9.2.0, I get this error



    When I go back to a PROJECT BACKUP made before the addition of the LP ROUTINES, this section of code works with no issues.

    What do you suggest?

    Thanks.

    -- Matt
  • Matt, I've tested your macro, works as expected:


    after running MyCaliperTool

    Nikita.
  • edited August 2016
    Nikita --

    I created a NEW PROJECT and put YOUR LP ROUTINES and MY MyCaliperTool into it and everything worked like a champ.



    For some reason the same code inside of the existing PROJECT is not working and seems to be generating conflicts with the existing routines.

    I'll see if I can figure out what is happening.

    Thank you very very much for your patience on this.

    -- Matt
Sign In or Register to comment.