Page 1 of 1

Cannot drop vensim context in MC DLL using python

Posted: Wed Oct 06, 2021 3:50 am
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

Re: Cannot drop vensim context in MC DLL using python

Posted: Thu Oct 07, 2021 1:27 pm
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.