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

What CODE will extract the PITCH LINE LENGTHS from from a PITCH WITH LINE FEATURE?

2021-06-06-162742

All --

I am working with an SAMPLE and an APP and we are currently using a set measurements that includes LINE FEATURES and ANGLE ANGLE FEATURES to measure something for a customer.

I would like to add two PITCH WITH LINE FEATURES




to the APP to measure another dimension on the IMAGE of the SAMPLE.

I have used the

    sf.FeatureType

in other CODE to properly handle the MEASUREMENT based on the FEATURE TYPE and its place in the SEQUENCE of FEATURES / MEASUREMENTS created by the user.

The PITCH WITH LINE FEATURE seems to be handled very much like a LINE FEATURE so I am having issues juggling the LINE FEATURES verses the PITCH WITH LINES FEATURES.

When I run this CODE

    Public Sub MMBPitchWithline()

        Debug.Clear

        'CONNECT WITH THE ACTIVE IMAGE
        Dim im2 As McImage=ThisApplication.ActiveImage

        'ERROR TRAP FOR NO IMAGE
        If im2 Is Nothing Then Exit Sub

        'CONNECT WITH THE MEASUREMENTS IN THE ACTIVE IMAGE
        Dim md2 As McMMData=im2.MeasurementsData

        'LOOP THROUGH THE FEATURES IN THE ACTIVE IMAGE

        Dim MyPWLCount As Integer = _
            0

        For Each sf As McMMSubFeature In md2.SubFeatures

'            If ( _
'                sf.FeatureType = _
'                    "mcmmsfLine" _
'                ) _
'                Then

                    Debug.Print "sf.Name"
                    Debug.Print sf.Name

                    Debug.Print "sf.FeatureType"
                    Debug.Print sf.FeatureType

                    MyPWLCount += _
                        1

                    Debug.Print "MyPWLCount"
                    Debug.Print MyPWLCount

                    'LEARN THE LENGTH FOR THE CURRENT LINE

                    Dim MyLength As Double = _
                        sf.Value(eMeasures.LnLength)

                    Debug.Print "MyLength
                    Debug.Print MyLength
'
'                End If

            Next

        md2.BeginUpdateBlock(False)

    End Sub


On this IMAGE (Image attached as 2021-06-06-162303.tif)



the IMMEDIATE WINDOW shows

sf.Name
PWL1
sf.FeatureType
mcmmsfLine
MyPWLCount
 1
MyLength
 5.46021070765929
sf.Name
PWL1PL4
sf.FeatureType
mcmmsfLine
MyPWLCount
 2
MyLength
 0.935572131396735
sf.Name
L2
sf.FeatureType
mcmmsfLine
MyPWLCount
 3
MyLength
 3.05630021341195
sf.Name
L3
sf.FeatureType
mcmmsfLine
MyPWLCount
 4
MyLength
 2.93328657804104
sf.Name
PWL4
sf.FeatureType
mcmmsfLine
MyPWLCount
 5
MyLength
 6.78636382614732
sf.Name
PWL4PL4
sf.FeatureType
mcmmsfLine
MyPWLCount
 6
MyLength
 0.842490789128647
 
which matches the DATA TABLE which shows

Feature Name    Length(mm)
PWL1    5.4602
PWL1PL4    0.9356
L2    3.0563
L3    2.9333
PWL4    6.7864
PWL4PL4    0.8425

A previous discussion on this FORUM at


provides some information about working with the PITCH WITH LINE FEATURES but it does not illuminate how to discriminate between PWL FEATURES and LINE FEATURES.

What CODE will allow me to step through the FEATURES in an IMAGE and know when I encounter a LINE FEATURE verses an PITCH WITH LINE FEATURE?

I would prefer to not use the NAME in the FEATURE NAME (like sf.name) because the APP is changing the FEATURE NAME (sf.name) as part of the flow of MAKING and EXTRACTING the MEASUREMENT DATA.

I believe that for this APP that the PWL FEATURES will only have 1 PITCH LINE but if the solution can indicate how to access multiple PITCH LINE LENGTHS, that would be super.  This is somewhat addressed in the FORUM ENTRY referenced above but I am hoping that since that was 2016, that there is a more elegant solution in 2021.

Thank you in advance for your assistance with this.

-- Matt

Best Answer

  • Answer ✓
    Hi Matt,

    You can check the FeatureType of the parent McMMFeature and also Flags. Here is the test macro:

        Public Sub TestPitch
            Dim md As McMMData=ThisApplication.ActiveImage.MeasurementsData
            For Each sf As McMMSubFeature In md.SubFeatures
                Debug.Print String.Format("{0} - parent type {1}, flags - {2}",sf.Name,sf.Parent.FeatureType, sf.Flags And McMMSubFeature.mcmmsfFlags.mcmmsffPPLine)
            Next
        End Sub
    The result may look like:

    PWL1 - parent type mmttPitchWithLine, flags - 0
    PWL1PL6 - parent type mmttPitchWithLine, flags - mcmmsffPPLine
    PWL1PL7 - parent type mmttPitchWithLine, flags - mcmmsffPPLine
    PWL1PL8 - parent type mmttPitchWithLine, flags - mcmmsffPPLine
    L2 - parent type mmttLine, flags - 0


    Yuri

Answers

  • 2021-06-07-095558

    Yuri --

    Super.

    I will let you know how it goes.

    Thanks.

    -- Matt

  • 2021-06-11-140853

    Yuri --

    I just wanted to follow up and say that I was able to use the PARENT.FEATURETYPE PROPERTY and a scan through the MEASUREMENTSDATA to determine the LENGTH of the 1st PITCH LINE for the APP that I am developing.

    Looking back through your example, I see that you pointed me at the

        sf.Flags And McMMSubFeature.mcmmsfFlags.mcmmsffPPLine

    to indicate the PITCH LINE but that was chopped off of display of the CODE on my browser.  I was able to write the routine with just

        PARENT.FEATURETYPE PROPERTY

    I may revisit this section of code and make it more elegant using the

        sf.Flags And McMMSubFeature.mcmmsfFlags.mcmmsffPPLine

    Thank you for your guidance on this and the other issues you have addressed over the years..

    -- Matt

Sign In or Register to comment.