Do they have a sample in C# for how you should use their SDK? That may help us figure out if something should be done differently in IronPython.
-Steve Steve Baer Robert McNeel & Associates www.rhino3d.com On Mon, Nov 7, 2016 at 1:25 PM, Djordje Spasic via Ironpython-users < ironpython-users@python.org> wrote: > Hello, > > I have an issue. I am using ironpython 2.7 editor called through Rhino 5 > <https://www.rhino3d.com/> application, and I load a single .dll file > from an application called MapWinGIS > <https://mapwingis.codeplex.com/releases>. Like so: > > dll_filePath = "C:\Program Files\MapWinGIS\Interop.MapWinGIS.dll" > clr.*AddReferenceToFileAndPath*(dll_filePath) > *import *MapWinGIS > > The problem is that I can only call a particular method *once*. > If try to do that the second time, the same method returns "False". When > method works correctly (the first time) it return: "True". > > The problem goes away if I restart the Rhino 5 application (and ironpython > 2.7 editor along with it). > > > Why is this happening? I contacted the developers of upper mentioned > MapWinGIS application, and they said that they can not replicate this > behavior and that I should ask this question on ironpython mailing list. > They suggested that I need to somehow *"free the memory before you do the > second run of the method"*. > > So to make my problem more clear, this is what happens: > > If run a script containing the this particular method twice, the first > call of the method returns "True", the second one "False": > > variable1a = "something1a" > variable1b = "something1b" > returnedValue1 = MapWinGIS.someClass.*someMethod1*(variable1a, variable1b) > # returns "True" > > variable2a = "something2a" > variable2b = "something2b" > returnedValue2 = MapWinGIS.someClass.*someMethod1*(variable2a, variable2b) > # returns "False" > > If run the same script again, both upper calls of > MapWinGIS.someClass.someMethod1 > method return "False". > If I restart my Rhino 5 application, then again the same thing happens: > "True" is returned on first MapWinGIS.someClass.someMethod1 call, while > "False" is returned on the second call. If run the script again, then they > both return "False". For every other run of the script, I get "False" on > both calls. And this continues until I restart Rhino 5. > > I perfectly understand that it is impossible for anyone from Ironpython > mailing list to know the exact cause of this problem. > > But can you at least help me with *"free the memory before you do the > second run of the method"* part? > > I tried deleting all the variables after the first call, calling the > garbage collector and also removing the .dll file from the list of loaded > assemblies. Like this: > > *import *clr > *import *gc > > dll_filePath = "C:\Program Files\MapWinGIS\Interop.MapWinGIS.dll" > clr.*AddReferenceToFileAndPath*(dll_filePath) > *import *MapWinGIS > > variable1a = "something1a" > variable1b = "something1b" > returnedValue1 = MapWinGIS.someClass.*someMethod1*(variable1a, variable1b) > # returns "True" > > # delete all variables > *del *dll_filePath; *del *variable1a; *del *variable1b; *del *returnedValue1; > *del *MapWinGIS > > # remove the .dll from the list of assemblies > *for *i,assembly *in **enumerate*(clr.References): > *if *assembly.*GetName*().Name == "Interop.MapWinGIS": > clr.References.*RemoveAt*(i) > break > > # collect garbage > gc.*collect*() > > > > dll_filePath2 = "C:\Program Files\MapWinGIS\Interop.MapWinGIS.dll" > clr.*AddReferenceToFileAndPath*(dll_filePath2) > *import *MapWinGIS > > variable2a = "something2a" > variable2b = "something2b" > returnedValue2 = MapWinGIS.someClass.*someMethod1*(variable2a, variable2b) > # returns "False" > > > But it is not working (I still get the "True" on first method call, and > "False" on second). > I also tried to exchange the *variable1a* and *variable1b* with > *variable2a* and *variable2b*. Or even use the same variables in both > MapWinGIS.someClass.someMethod1 calls. Still, no improvement. > > The MapWinGIS.someClass.someMethod1 that I am calling is actually: > MapWinGIS.UtilsClass.OGR2OGR > <https://web.archive.org/web/20160305060402/http://www.mapwindow.org/documentation/mapwingis4.9/class_utils.html#a269f6ab098480f14202a530d7e278407> > . > I named it MapWinGIS.someClass.someMethod1 to make it easier for others > to follow the code. Not sure if this was good idea. If it wasn't I > apologize. > > > This issue is driving me crazy. I would be very grateful for any kind of > advice. > Thank you in advance! > > > Kind regards, > Djordje Spasic > > > _______________________________________________ > Ironpython-users mailing list > Ironpython-users@python.org > https://mail.python.org/mailman/listinfo/ironpython-users > >
_______________________________________________ Ironpython-users mailing list Ironpython-users@python.org https://mail.python.org/mailman/listinfo/ironpython-users