0

I am using vissim com and trying to integrate python. After I load, the simulation in vissim starts. But when I add a link and give other commands GetMultiAttValues etc (last 3 commands of code given ), it doesn't change anything and does not give the data of the command ( doesn't add links or give details). My code is here given below.

Vissim = com.Dispatch("Vissim.Vissim")
file="D:\Simulation\MLK2.1rough.inpx"
Vissim.LoadNet(file)
Vissim.Simulation.RunContinuous()
k=Vissim.Net.Links
Vissim.Net.Links.AddLink(42, 'LineString(0 30, 200 200)', [3.5, 3.5])
print(k.GetMultiAttValues('Name'))
print(Vissim.Net.Links.ItemBykey(1).AttValue('Length2D'))
Jewel221
  • 11
  • 2
  • I don't think the `RunContinuous` function is blocking, and you can't add a link while the simulation is running. – user1558604 Mar 17 '21 at 02:26
  • I tried commenting out the Runcontinuous function and now it gives name attributes for this command ```print(Vissim.Net.Links.GetMultiAttValues('Name'))``` But for ```print(Vissim.Net.Links.ItemBykey(5).AttValue('Length2D'))``` , it says com_error: (-2147352573, 'Member not found.', None, None) . – Jewel221 Mar 17 '21 at 02:33
  • Is everything working as expected now? – user1558604 Mar 17 '21 at 02:34
  • 1. for every print command I give, vissim starts newly for output of my new command. and 2. ```print(Vissim.Net.Links.ItemBykey(5).AttValue('Length2D'))``` , this command gives``` com_error: (-2147352573, 'Member not found.', None, None) ``` error but the 5 key is present in the vissim link details. – Jewel221 Mar 17 '21 at 02:38
  • It is working. I used k instead of K, a type error in 'ItemByKey' .Thanks very much – Jewel221 Mar 17 '21 at 02:45
  • Ah, Glad I was able to help. – user1558604 Mar 17 '21 at 02:45
  • Most of the Vissim community exchanges happen on LinkedIn (https://www.linkedin.com/groups/2524087). So you might get faster answers there. Or you could also contact PTV's technical support. – Sedenion Dec 13 '21 at 14:41

0 Answers0