Fetch Data (simple)
Hi,
Again a beginner's question but I had to give up:
Can't get a value for StDevIntIM, what is wrong?
Public Function Convert8bitGrey() As SimpleScript Convert8bitGrey = New SimpleScript Dim doc1, image1, doc2, StDevIntIM
'....a set of functions before such as conversion, measurement definition etc....
'.
'.
With Application.DocumentCommands.Active(Convert8bitGrey) .Run(doc2) End With With Measure.MeasurementsCommands.ExecuteCount(Convert8bitGrey) .Run(doc2) End With With Automate.ScriptingCommands.FetchData(Convert8bitGrey) .Expression = "<McMMData>.Statistics(eMeasures.RgnStdDevIntensity).Mean" If .Run(doc2) Then StDevIntIM = doc2.Statistics(eMeasures.RgnStdDevIntensity).Mean MsgBox("")&StDevIntIM 'is never displayed End If End With MsgBox("")&StDevIntIM ' this is empty End Function
The if .Run(doc2) also not .run() statement or whatever I tried does not work.
The first Msgbox is never displayed, which means to me that ...FetchData().run does not exist?
How do I get the value into the variable?
Thx Daniel
0
Best Answer
-
Hi Daniel,
Here is a macro with the required syntax to count objects and access measurements statistics.
PierrePublic Sub GetStatistics() Dim doc1, mdata, stdevInt Dim stats As StatsClass With Application.DocumentCommands.Active(Nothing) .Run(doc1) End With With Measure.MeasurementsCommands.ExecuteCount(Nothing) .Run(doc1) End With With Measure.MeasurementsCommands.GetData(Nothing) .Run(doc1, mdata) End With With Automate.ScriptingCommands.FetchData(Nothing) .Expression = "<McMMData>.Statistics(eMeasures.RgnStdDevIntensity)" If .Run(mdata, stats) Then stats = mdata.Statistics(eMeasures.RgnStdDevIntensity) MsgBox stats.Mean End If End With End Sub
0
Answers
-
Hi Daniel,The variable should be inside brackets: MsgBox(StDevIntIM).Nikita.0
-
That's it.:-)
For completeness:
Here the sub solution:
Public Sub GetVars Dim im As McImage=ThisApplication.ActiveImage If im Is Nothing Then Exit Sub Dim md As McMMData=im.MeasurementsData Dim StDevIntIM2, MeanIntIM If md.SubFeatures.Count>0 Then Debug.Print "Mean Int = " & md.SubFeatures(0).Value(eMeasures.RgnDensity) MeanIntIM = md.SubFeatures(0).Value(eMeasures.RgnDensity) StDevIntIM2 = md.SubFeatures(0).Value(eMeasures.RgnStdDevIntensity) Debug.Print MeanIntIM Debug.Print StDevIntIM2 End If End Sub
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