Cannot drop vensim context in MC DLL using python

Use this forum to post Vensim related questions.
Post Reply
ralpu
Junior Member
Posts: 2
Joined: Wed May 30, 2018 2:19 pm
Vensim version: DSS

Cannot drop vensim context in MC DLL using python

Post by ralpu »

Hi All. I need help or advice regarding the issue I have at the moment.
I am trying to create an python API using the Vensim MC DLL.
I am wrapping the vensim functions using ctypes in python.
The code works fine and I can create as many context (VensimContextAdd) as needed.
The problem occurs when I try to do VensimContextDrop. A second call to the VensimContextDrop abruptly terminates the program.

Here is a simple python code to show the problem

Code: Select all

import ctypes

# load vensim multicontext dll
vensim = ctypes.windll.vendlstc64

# create vensim context and put context number in list
cid_list = [vensim.VensimContextAdd(1) for x in range(5)]

# view context numbers
print(f"list of cid = {cid_list}")

# drop each context in the cid_list
for cid in cid_list:
    ret = vensim.VensimContextDrop(cid)
    print(f"Dropped context cid={cid}")

print("END")
The result of above code looks like this

Code: Select all

PS C:\test> python .\main.py
list of cid = [1, 2, 3, 4, 5]
Dropped context cid=1
From the example, only the first call to VensimContextDrop (cid=1) was successful.
The second call terminated the program. If the call VensimContextDrop was all successful it would executed up to print("END").

Hope someone who has idea about the problem can advise me on this?

Versions I'm using:
Vensim MC DLL : Vensim_9_0_1_VensimMCDLLSetup_30352 - (vendlstc64.dll)
Python version: python 3.9

P.S. Anyone with sample python code utilizing the Vensim MC DLL can share them with me? Would really appreciate it.

Thank you very much in advance
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Cannot drop vensim context in MC DLL using python

Post by Administrator »

I've found the issue. Can you contact us at vensim@vensim.com with your licence details and I'll get a new build of the DLL to you.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply