Create a MEASUREMENT OBJECT from an ARRAY of POINTS . . .
2017-11-29-113301
All --
In the NEWMACRO shown below, I have recorded MANUALLY creating a MEASUREMENT OBJECT with 4 POINTS.
I would like to modify this so that I feed an ARRAY of BOUNDARY POINTS to
Measure.MeasurementsCommands.Add
and have a new MEASUREMENT OBJECT appear on my image.
How is the best way to achieve this?
Thanks in advance.
-- Matt
-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-
All --
In the NEWMACRO shown below, I have recorded MANUALLY creating a MEASUREMENT OBJECT with 4 POINTS.
I would like to modify this so that I feed an ARRAY of BOUNDARY POINTS to
Measure.MeasurementsCommands.Add
and have a new MEASUREMENT OBJECT appear on my image.
How is the best way to achieve this?
Thanks in advance.
-- Matt
-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-
Public Function NewMacro() As SimpleScript NewMacro = New SimpleScript Dim image1, meas1 With Application.RibbonCommands.SelectRibbonTab(NewMacro) .TabName = "Measure" .Run() End With With Application.DocumentCommands.ActiveImage(NewMacro) .Run(image1) End With With Measure.MeasurementsCommands.Add(NewMacro) .MeasurementType = McMeasurements.enumMMSTypes.mmtsPolygon .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .Points.Add(New System.Drawing.PointF(211.9235F,302.3622F)) .Points.Add(New System.Drawing.PointF(272.6659F,207.874F)) .Points.Add(New System.Drawing.PointF(175.4781F,161.9798F)) .Points.Add(New System.Drawing.PointF(137.6828F,218.6727F)) .FeatureName = "P2" .SnapFeature = False .Run(image1, meas1) End With End Function
0
Best Answer
-
Hi Matt,
It should be straight forward. As you can see, the Points property of the command is a List of PointF objects, your macro adds 4 points to the list. You can add any number of points to the list from your array using a loop.
Yuri
0
Answers
Yuri --
I was not considering putting a LOOP within the WITH.
I'll give that a go.
Thanks for the guidance.
-- Matt
Yuri --
Using the advice you gave me above, I modified the routine that I am working on.
The routine shown below takes the BOUNDARY for each OBJECT / FEATURE and makes a MIRROR IMAGE of the OBJECT / FEATURE across the X AXIS at the top of the OBJECT / FEATURE.
This can be seen in the DEVELOPMENT and TESTING IMAGES below with:
1) Original Image before DARK COUNT
2) Original Image after DARK COUNT
3) Original Image after MirrorAndFilter
I have not wired in the CODE for the FILTER yet.
Thanks again.
-- Matt
-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-
BEFORE COUNT
AFTER COUNT
AFTER MIRROR
The macro looks good! The only note is that you should not convert coordinates to calibrated units as both GetFeaturePoints and the Add command deal with uncalibrated pixel coordinates.
Yuri
Yuri --
Thank you for the reminder about that.
I had it on my TO TO LIST to check this on a CALIBRATED IMAGE but I got distracted.
I'll revise, test, and post ASAP.
Thanks again.
-- Matt