Page 1 of 1

help with vensim_get_data in visual studio 2008

Posted: Mon Jul 25, 2011 3:28 pm
by Paul Anim
Hi,

I need to display all the variable data after simulation. Output the result of the vensim_get_data to say listbox or Datagrid.

the final result of what i need to do is to display the data for each variable in a tabular form for each run.

In the long run, I will like to use these data to plot graphs

thanks

Re: help with vensim_get_data in visual studio 2008

Posted: Mon Jul 25, 2011 5:08 pm
by gwr
Hi Paul,

I do not know about Visual Studio but you should get all you want by running your model saving the runs to 'runname.vdf'. You can then go to the menu and choose 'Model>Export Dataset...' from the main menu. This let's you choose your saved runs and convert them into excel of tab delimitered files. Using Pivot charts and the like in Excel for example let's you plot nice 3D surfaces and the like. It is a bit experimenting.

Kind regards,

Guido

Re: help with vensim_get_data in visual studio 2008

Posted: Mon Jul 25, 2011 5:47 pm
by Administrator
Paul Anim wrote:Hi,

I need to display all the variable data after simulation. Output the result of the vensim_get_data to say listbox or Datagrid.

the final result of what i need to do is to display the data for each variable in a tabular form for each run.

In the long run, I will like to use these data to plot graphs

thanks
So is vensim_get_data working for you? The C++ example that ships with Vensim uses it to get data from runs, have you tried compiling and running that?

Re: help with vensim_get_data in visual studio 2008

Posted: Tue Jul 26, 2011 11:30 am
by Paul Anim
Administrator wrote:
So is vensim_get_data working for you? The C++ example that ships with Vensim uses it to get data from runs, have you tried compiling and running that?
Hi,
I am having a problem with the vesnim_get_data. I am not into C++ but rather VB. So i compiled the vb example that was shipped with vensim. since i am using vb.net 2008, and the example seems to be in vb5 or so. I used vb2008 to upgrade the code and I was able to compile the example in vb2008. Most of the features on the example works except the get data button(which runs vensim_get_data command) and the plot command.
What i want to do is to be able to display output of the vensim_get_data command. I want output the vensim_get_data to grid control in vb2008

this is the code for the get data button
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
tpoints = vensim_get_data("base.vdf", "population", "time", rval(1), tval(1), 500)
tpoints = vensim_get_data("bobblah.vdf", "population", "time", rval2(1), tval(1), 500)


End Sub

This is also the code for the Plot graph button

Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click
Dim i As Integer
Dim NumPoints As Integer
Dim NumSets As Integer
Dim ThisSet As Integer
Dim ThisPoint As Integer
Dim GraphData As Integer

If tpoints = 0 Then Exit Sub
'UPGRADE_ISSUE: PictureBox property Graph1.DrawMode was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
'Graph1.DrawMode = 0
'Graph1.DrawMode = 0
'UPGRADE_WARNING: Couldn't resolve default property of object Graph1.NumPoints. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'

NumPoints = tpoints

NumSets = 2
'UPGRADE_WARNING: Couldn't resolve default property of object Graph1.ThisSet. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
ThisSet = 1
For i = 1 To tpoints
'UPGRADE_WARNING: Couldn't resolve default property of object Graph1.ThisPoint. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
ThisPoint = i
'UPGRADE_WARNING: Couldn't resolve default property of object Graph1.GraphData. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
GraphData = rval(i)
Next i
'UPGRADE_WARNING: Couldn't resolve default property of object Graph1.ThisSet. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
ThisSet = 2
For i = 1 To tpoints
'UPGRADE_WARNING: Couldn't resolve default property of object Graph1.ThisPoint. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
ThisPoint = i
'UPGRADE_WARNING: Couldn't resolve default property of object Graph1.GraphData. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
GraphData = rval2(i)
Next i




'UPGRADE_ISSUE: PictureBox property Graph1.DrawMode was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
'Graph1.DrawMode = 2
End Sub

Private Sub Command4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command4.Click
Dim result As Object
Dim winint As Integer
winint = Me.Picture1.Handle.ToInt32
'UPGRADE_WARNING: Couldn't resolve default property of object result. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
result = vensim_tool_command("WORKBENCH>Causes Tree", winint, 0)


End Sub

Thanks

Re: help with vensim_get_data in visual studio 2008

Posted: Tue Jul 26, 2011 8:09 pm
by Administrator
So what happens, does the vensim_get_data command work ok? Does it retrieve the values for you?

Re: help with vensim_get_data in visual studio 2008

Posted: Wed Jul 27, 2011 10:14 am
by Paul Anim
Administrator wrote:So what happens, does the vensim_get_data command work ok? Does it retrieve the values for you?
Thanks so much for your help.
I finally got the vensim_get_data to work. i tested it by collecting the data to a listbox. Below is the sample in Vb2008 that i used

Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click

tpoints = vensim_get_data("bobblah.vdf", "population", "time", rval2(1), tval(1), 500)

Dim i As Integer

For i = 1 To tpoints
lsgetdata.Items.Add(rval2(i))
lsgetdata2.Items.Add(tval(i))
Next
End Sub


Thanks :lol: