Home Image-Pro Automation (Macros, Apps, Reports)

Variable into data collector

Hi,

Is there a way to get a variable I have filled in a sub (for instance a corrected number of objects) into the data collector table?

I tried a few things but without success so far (e.g. parsing a System.Double from a function into the expression of Region:Area(count)

Thanks

Daniel


Best Answer

  • edited July 2015 Answer ✓
    Hi Daniel,

    Nikita's example is a good start, but if you need more details I've attached an app that demonstrated how to control Data Collector. Check the app's code to see how it works.

    Regards,

    Yuri

Answers

  • Hi Daniel,

    I think, this example will help you. What I did:
    1) Added user defined measurement "MyTest" (double) into the "Image" table without expression,
    2) Collect the data into the Data Collector (now, you have a row in the Image table, "MyTest" value is empty)
    3) Run macro Set_Value_in_DataCollector (this macro will set value in the last row)

        Public Function Set_Value_in_DataCollector() As SimpleScript
            Set_Value_in_DataCollector = New SimpleScript
            Dim ds
    
            With Measure.Data.CollectorCommands.GetData(Set_Value_in_DataCollector)
                .Run(ds)'get DataCollector data set
            End With
    
            With Automate.ScriptingCommands.CodeCommand(Set_Value_in_DataCollector)
                If .Run() Then
                    ' User Code Here
                    Dim ds2 As System.Data.DataSet = ds
                    Dim dt As System.Data.DataTable = ds2.Tables("Image")'get table
                    Dim dr As System.Data.DataRow = dt.Rows.Item(dt.Rows.Count-1)'get last row
    
                    dr.Item("MyTest")=123.456'set value
                End If
            End With
    
        End Function

    Thanks,

    Nikita.

  • Thanks to both of you!
  • Hi Nikita, 

    I tried your solution for Measurement Stats data table and a table column "Corrected Count", however it tells me that it does not belong to the data table (although there). So could you specify "1) Added user defined measurement "MyTest" (double) into the "Image" table without expression" a bit more concrete?

    Hi Yuri, 

    Could not find an attached app.  Is there a link?

    Thx

    Daniel



  • Hi Daniel,

    I'm attaching it again (it looks like when the answer is marked as Accepted, the attachment disappears).

    Yuri
  • Data collector app.
  • Yes - sorry and thx. I'll remember. 
  • Hi Daniel,

    You can add the user defined measurements into the regular tables:

    The stats table generated automatically and I'm not sure you have any access to it.

    Thanks,
    Nikita.
Sign In or Register to comment.