twk Posted October 21, 2015 Share Posted October 21, 2015 Hello again Quick question, how do you get immediate feedback while developing plugins in Python. eg I have a plugin object which I'm writing in Aptana. This is the code in the PIO's main script window. from TestPlugin import MainGuy #these are setup in the env paths MainGuy() the MainGuy.py has this code global LineLength objectName, objectHand, recordHand, wallHand = 0, 0, 0, 0 LineLength = vs.PLineLength ok, objectName, objectHand, recordHand, wallHand = vs.GetCustomObjectInfo( objectName, objectHand, recordHand, wallHand ) if ok: vs.Locus(0,0) vs.Locus(LineLength,0) vs.Rect(0, 0, LineLength, 50) if __name__=='__main__': mainguy() pass if I change say a value for the vs.rect call from 50 to 100 vs.Rect(0,0,LineLength, 100) from Aptana, this doesnt get reflected in vectorworks until I restart VW. I have the Session in Developer Mode set in the vectorworks preferences and still I need to restart. This wasn't the case in Vectorscript and includes. Is this normal behaviour for Python/Aptana or am I doing something wrong? Quote Link to comment
twk Posted October 22, 2015 Author Share Posted October 22, 2015 ..aaaand its not called 'immediate feedback' its called python caching. Found this thread here started by Dieter @ DWorks. Can we disable Python caching? Interesting read. The last post though solved my problem. I use a different approach to solve this issue. I created a command that clears all the modules in a designated folder. (In the example : myLibrary) It actually removes the modules from sys.modules. Python will therefor import them again at the next import statement. I find this much easier than placing "reload(module)" statements everywhere in my code. (especially since they need to be removed for deployment) import sys modulesToDelete = [] for m in sys.modules: moduleName = str(m) if "myLibrary." in moduleName: modulesToDelete.append(moduleName) currentModule = __name__ for mod in modulesToDelete: if mod != currentModule: # Python cannot delete the current module del sys.modules[mod] Thanks Musisback! Quote Link to comment
Dieter @ DWorks Posted October 24, 2015 Share Posted October 24, 2015 Hello again Quick question, how do you get immediate feedback while developing plugins in Python. eg I have a plugin object which I'm writing in Aptana. This is the code in the PIO's main script window. from TestPlugin import MainGuy #these are setup in the env paths MainGuy() If you do this instead, you won't need to restart VW: import TestPlugin TestPlugin.MainGuy() Only other python files that you reference in that file will acquire a restart if they are changed, but not that main file if you reference it like this. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.