Processing on Datacollector
Hi There
I have this macro (with A LOT of help from Yuri), that generates data in the datacollector, The processed images are not visible - the same goes for the datacollector. That saves my a lot of time when running as a batch. After batch processing are have a small script that empties the datacollector into Excel for further calculations. It would nice to make the Excel VBA coding directly in ImagePro, again to save time and trouble.
I have been experimenting a little and this line in my macro:
I have this macro (with A LOT of help from Yuri), that generates data in the datacollector, The processed images are not visible - the same goes for the datacollector. That saves my a lot of time when running as a batch. After batch processing are have a small script that empties the datacollector into Excel for further calculations. It would nice to make the Excel VBA coding directly in ImagePro, again to save time and trouble.
I have been experimenting a little and this line in my macro:
Public Function FD_Measure(doc1 As Object) As SimpleScript FD_Measure = New SimpleScript - bla bla bla - bla bla bla - bla bla bla
Call DoSomething() End Function Then made this simple sub routine: Private Sub DoSomething() Debug.Print Now() End Sub It works!:-))) But here comes the question - In this DoSomething, how can I access the data in the datacollector. Loop through them, put them in arrays etc etc. I have all that code from Excel VBA. I need something like (in mumbo-jumbo language): For i 1 to Number_Of-lines_in-Datacolletor myParamx(i) = Parameter1_In_Collector(i) myParamy(i) = Parameter2_In_Collector(i) Next
Does it make any sence!? - Torben
0
Answers
The data in DataCollecter is saved as System.Data.DataSet (see https://msdn.microsoft.com/en-us/library/system.data.dataset(v=vs.110).aspx ).
Here is a sample macro that shows how to print one of the tables to Output window (you can use Debug.Print instead).
The data from Output window can be sent to Excel using context menu.
Yuri
-Torben
Dim dt As System.Data.DataTable=ds.Tables(1)
Yuri
Public Sub PrintDCdata 'get Data Collector doc (global) Dim dcDoc As MediaCy.Addins.DataCollector.McDataCollectorDocument=MediaCy.Addins.DataCollector.McDataCollectorAddin.ThisAddin.Document Dim tmp(1000,5) As Double Dim r As Integer Dim c As Integer 'get data collector data as DataSet Dim ds As System.Data.DataSet=dcDoc.Data 'get the first table Dim dt As System.Data.DataTable=ds.Tables(1) Dim s As String="" ThisApplication.Output.Show 'print column names Dim col As System.Data.DataColumn For Each col In dt.Columns s+=col.Caption & vbTab Next r=0 c=0 ThisApplication.Output.PrintMessage(s)'can be used instead of Debug.Print 'print data For Each row As System.Data.DataRow In dt.Rows r+=1 s="" For Each col In dt.Columns c+=1 s+=row(col).ToString & vbTab tmp(r,c) = row(col) Next ThisApplication.Output.PrintMessage(s) Next 'Debug.Print r.ToString & vbTab & c.ToString End Sub
You have to reset column index in the beginning of every row. Add c=0 to row loop.
Yuri
With Automate.ScriptingCommands.CodeCommand(FD_Measure) If .Run() Then ' User Code Here PrintDCdata End If End With
You can search the forum for CodeCommand to see more examples.
Yuri