I have been learning to program with Poser Python. I have purchased Phillip Cook's tutorial, but it was not as good as I thought. We can learn Python from any book, so there wasn't necessary for him to try to teach the basics of the language there. What I want to know is how to use Poser Python, not Python itself. There are plenty of better and more complete books for plain Python in the market.
One thing that makes it harder is that Poser uses an older version of Python that has been retired by the mainstream academia nowadays. Most books are for current Python 3, while Poser uses old-school version 2.6. It's difficult to know if something doesn't work because of version differences, or because of the particular way Poser handles it.
Nonetheless, last night I have managed to make a script that builds a texture overlay, and inserts itself into the existing material on Dawn's face. This only works if the face texture is plugged into the "diffuse color" channel. For materials that use the "alternative diffuse", I would have to write some more code. I am not using any graphical interfaces yet, and I was happy enough when the script worked.
My grudge was when I wanted to reuse this code by turning it into a class. After that was done, I couldn't import the class in any possible way I have tried. I have tried this for 2 days and gave up. Now I suspect that for Poser Python to import a class, maybe it has to be placed in a special folder, or else it won't recognize it. I have also suspected that maybe Poser Python forces all code to be self-contained in the same file, so we cannot break the code into separate classes like we do in normal programming. I don't really know. In Poser, the "import" statement from regular Python only seems to work with pre-existing classes, but not with new ones we create.
To test that, I have examined scripts created by other people, but nobody seems to want to split a program into classes. All examples I have found contain all classes in the same file, which is not how good programming is done. This approach leads to confusing programs that are very hard to debug. Most examples don't even use classes, but instead just a list of function calls, which is even worse.
I am placing my Python files at "Runtime\Python\poserScripts\ScriptsMenu\Ken1171\". I have assumed that if all files are in the same folder, I could just import them straight away, but no - Poser Python doesn't let me import any files other than its own existing classes. Even when I have managed to import a class, it claims it doesn't contain any methods. This happens to both files with a class, or with just plain series of functions. It appears that Poser Python cannot import anything other than its own files?
Any hints on why this happens?
One thing that makes it harder is that Poser uses an older version of Python that has been retired by the mainstream academia nowadays. Most books are for current Python 3, while Poser uses old-school version 2.6. It's difficult to know if something doesn't work because of version differences, or because of the particular way Poser handles it.
Nonetheless, last night I have managed to make a script that builds a texture overlay, and inserts itself into the existing material on Dawn's face. This only works if the face texture is plugged into the "diffuse color" channel. For materials that use the "alternative diffuse", I would have to write some more code. I am not using any graphical interfaces yet, and I was happy enough when the script worked.
My grudge was when I wanted to reuse this code by turning it into a class. After that was done, I couldn't import the class in any possible way I have tried. I have tried this for 2 days and gave up. Now I suspect that for Poser Python to import a class, maybe it has to be placed in a special folder, or else it won't recognize it. I have also suspected that maybe Poser Python forces all code to be self-contained in the same file, so we cannot break the code into separate classes like we do in normal programming. I don't really know. In Poser, the "import" statement from regular Python only seems to work with pre-existing classes, but not with new ones we create.
To test that, I have examined scripts created by other people, but nobody seems to want to split a program into classes. All examples I have found contain all classes in the same file, which is not how good programming is done. This approach leads to confusing programs that are very hard to debug. Most examples don't even use classes, but instead just a list of function calls, which is even worse.
I am placing my Python files at "Runtime\Python\poserScripts\ScriptsMenu\Ken1171\". I have assumed that if all files are in the same folder, I could just import them straight away, but no - Poser Python doesn't let me import any files other than its own existing classes. Even when I have managed to import a class, it claims it doesn't contain any methods. This happens to both files with a class, or with just plain series of functions. It appears that Poser Python cannot import anything other than its own files?
Any hints on why this happens?