I’ll need some time to look into questions 1 and 2, or @chris will respond when he has time, but I can take a stab at answering question 3.
So for some reason the IronPython interpreter is choosing the path to your Desktop UWG, rather then using your Rhino scripts folder exclusively. I believe the way the sys.path works in Python, it selects the first UWG folder it finds in the list of all directories in sys.path. And in this case Rhino adds the scripts folder to the list of directories for IronPython to search in the sys.path when it starts. At some point, I assume you are adding your desktop directory to the sys.path, which is why the interpreter is going there to find the UWG, before going to the Rhino scripts folder.
You can confirm this by printing your sys.path, and you should see the desktop directory there before (i.e at a lower index) then the Rhino scripts directory.
I’m not sure how the UWG from your desktop is getting added there but a couple of things to check out:
- If you are running the desktop UWG at any point, while you have Rhino open, you might be using the same interpreter, which is therefore inserting it’s path before the Rhino scripts path.
- You may have added your desktop or related directory to the top of your to the environment variable PYTHONPATH i.e like so:
.
(Caveat, this is for Cpython, but I think similiar for IronPython.
So making sure to insert the correct path to the Rhino scripts version at index 0, should fix this.
Is this what you tried with the sys library?
sys.path.insert(0, 'C:\\Users\\%User%\\AppData\\Roaming\\McNeel\\Rhinoceros\\6.0\\scripts')
You can also try this just to make sure:
sys.path.insert(0, 'C:\\Users\\%User%\\AppData\\Roaming\\McNeel\\Rhinoceros\\6.0\\scripts\\UWG')
A common mistake is to use append rather then insert, and not fix the order problem. If you are using insert, I think that should work… As long as you run that at the beginning of any Dragonfly session, it should force the IronPython editor to search the Rhino scripts directory first. It may not be good coding practice, because you are adding redundant paths, but it should work.
Let me know if you’ve tried that. Alternatively, print the sys.path before and after this is occurring, and we can at least confirm if path order is the cause of this problem.
Saeran