After merging objects, there are issues with GetFeaturePoints
Hello everyone,
My operation steps are roughly as follows:
Click on an object with the mouse and retrieve the relevant data of this object.
Version: Image Pro 10 10.0.14
I have a question. When I merge multiple objects, the resulting merged object will be assigned a new identification number.
Public Sub test
If ThisApplication.Images.Count = 0 Then Exit Sub
Dim im As McImage = ThisApplication.ActiveImage
Dim dt As McMMData = im.MeasurementsData
If dt.SubFeatures.Count = 0 Then Exit Sub
Dim numpt As Integer = 0
Dim select_feat As McMMSubFeature
Dim pt() As SINGLEPOINT
If dt.SubFeatures.Count > 1 Then
select_feat = select_object("Select Object", dt)
MsgBox(select_feat.FeatureIndex.ToString())
End If
' Problem Here Get the number of points for the selected sub-feature
numpt = dt.SubFeatures.Item(select_feat.FeatureIndex).GetFeatures.GetFeaturePoints(select_feat.FeatureIndex, pt)
End Sub
' Function to select an object by clicking on the workspace
Private Function select_object(prompt As String, md As McMMData) As McMMSubFeature
Dim window1, doc1
Dim clickedPoint As System.Drawing.PointF
Dim sf As McMMSubFeature
With MediaCy.Automation.Application.WindowCommands.Active(Nothing)
.Run(window1)
End With
With Automate.ScriptingCommands.ClickOnWorkspace(Nothing)
.Prompt = prompt
.SelectDocuments = True
.Run(window1, doc1, Nothing)
If .Status = McCommand.TaskStatus.IsProcessed Then
For Each sf In md.SelectedSubFeatures
Next
End If
End With
Return sf
End FunctionFor example
1.before the merger,the index of this object is 12.
2.After merging, the index of this object will be the second group of classes


3.cause to get the wrong object.
numpt = dt.SubFeatures.Item(select_feat.FeatureIndex).GetFeatures.GetFeaturePoints(select_feat.FeatureIndex, pt)
How can I get the data of the selected object instead of just its index number?
Waiting for a response, thank you, everyone.
Tagged:
0
Best Answer
-
Hi Kyle1996,
After merging of objects a new McFeatures are created, so you cannot use the index of the feature to get it from "Subfeatures" list. You must use select_feat directly, like this:numpt = select_feat.GetFeatures.GetFeaturePoints(select_feat.FeatureIndex, pt)
Test macro:Public Sub GetSelectedFeature Dim md As McMMData = ThisApplication.ActiveImage.MeasurementsData If md.SelectedSubFeatures.Count = 0 Then Exit Sub Dim select_feat As McMMSubFeature = md.SelectedSubFeatures(0) Debug.Print(select_feat.Name) Dim pt As Object Debug.Print(select_feat.GetFeatures.GetFeaturePoints(select_feat.FeatureIndex,pt)) End Sub
Yuri0
Answers
-
Hi,YuriG
This was successful, thank you for your response!
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions
