Add measurement conditions
Hi,
We developed a macro on IP-10 version 10.0.10
How can I add other conditions to the existing [Selected Measurement/Filters].
Because the macro will use [New System.Collections.Generic.List(Of MeasFilterEntry)] to create a new filter, I need to add a new one to the old condition.
Thanks!
We developed a macro on IP-10 version 10.0.10
How can I add other conditions to the existing [Selected Measurement/Filters].
Because the macro will use [New System.Collections.Generic.List(Of MeasFilterEntry)] to create a new filter, I need to add a new one to the old condition.
With Measure.MeasurementsCommands.Options(NewMacro)
.SelMeasurements = New MeasCollection()
.SelMeasurements.Add( New MeasEntry(eMeasures.RgnArea))
.Segmentation.FilterRanges = New System.Collections.Generic.List(Of MeasFilterEntry)
.Segmentation.FilterRanges.Add( New MeasFilterEntry(eMeasures.RgnArea,0R,20R))
.Run(doc1)
End With
Thanks!
0
Answers
The easiest way is to record a macro where you define multiple filters, so you will see the code and can edit it, if necessary.
But I would recommend you using IQO file to restore all your measurements filters and other measurement options., such as segmentation thresholds or recipe Just set all your options and filters, save the measurement options to an IQO file, then activate recording and load IQO file and click the Count and use that macro for you analysis.
You can check this video that demonstrates using of IQO files in macros https://youtu.be/GytLqW3mXxE
Regards,
Yuri
Thank you for your reply
Thanks!
Public MinArea As Double=0 Public MaxArea As Double=50 Public Sub SetNewRanges With Measure.MeasurementsCommands.Options(Nothing) .SelMeasurements = New MeasCollection() .SelMeasurements.Add( New MeasEntry(eMeasures.RgnArea)) .Segmentation.FilterRanges = New System.Collections.Generic.List(Of MeasFilterEntry) .Segmentation.FilterRanges.Add( New MeasFilterEntry(eMeasures.RgnArea,MinArea,MaxArea)) .Run(ThisApplication.ActiveImage) End With End Sub
where you set MinArea and MaxArea from your code and then call SetNewRanges.
Yuri
Thank you for your reply
But, I use this code, the old conditions will be cleared.
I want to keep the old [IQO] file filter content.
and
When I press the button, the condition of [area] will be added.
Is there any way to achieve it?
Thanks!
Public MinArea As Double=35 Public MaxArea As Double=1E+308 Public Sub SetNewAreaRanges Dim im As McImage=ThisApplication.ActiveImage If im Is Nothing Then Exit Sub Dim md As McMMData = im.MeasurementsData Dim mArea As MeasEntry = New MeasEntry(eMeasures.RgnArea) With md.Options.Segmentation Dim f As MeasFilterEntry If .FilterRanges.ContainsKey(mArea.CombinedName) Then 'modify existing range f = .FilterRanges(mArea.CombinedName) f.RangeStart = MinArea f.RangeEnd = MaxArea End If End With End Sub
Yuri
Thank you for your reply
I try the code you suggested.
But,in this paragraph 【.FilterRanges.ContainsKey(mArea.CombinedName)】judgment formula.
Because I haven’t added a [area] condition yet, it will always be in [False] state.
And I try 【.Options.SelMeasurements.Add( New MeasEntry(eMeasures.RgnArea))】when there is no [area] item. Can add [area] item, but it is in [unchecked] state.
So,【.FilterRanges.ContainsKey(mArea.CombinedName)】judgment formula still [False].
How can I let it in [checked] state ?
This is the event I want. (like this picture)
Is there a better way to achieve?
Thanks!
I adjusted a part,and that works.
Thanks for your help !
Yuri