Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
Thanks for this @adp001.
I don't want to take this thread off topic, but how would you estimate the difficulty of bolting an OS installed Python3 into Poser?
I see from other threads that the "poser" module is effectively hardcoded in Poser itself; are you aware of what hooks are required for Poser to integrate with a particular Python installation?
I've sitemailed Stefan to see if he's willing to shed light on the matter, but it would be great if it were possible to test things in advance of Poser 12, which I assume will have to be Python 3 ready, since 2.7 is past end of life as of Jan 1st 2020.
Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.
Don't worry too mutch about Python3. Most Python 2 scripts will run without many changes. And most of the necessary changes can be done with a little script.
You may test it with my lib. This lib is written P3 compatible :) If you use PyCharm, load your own script (with the POSER_FAKE import) and set the interpreter to Python 3. PyCharm will then show you possible errors in the script.
And here is the new version.
If you can, tell me if it works with P12. Thanks.
Hi, I am a newbie here at Rosity. Just wanted to ask what is this FakePoserLib3 used for? I use Sublime Text to write my Python code, and I wonder if this would allow me to debug from within the editor? Structure has mentioned it is possible to connect Sublime Text with Poser 12 by creating a new profile to use with Tools -> Build System, but that didn't work in my attempts. All it does is open the default Poser scene, no matter what code is executed. I wonder if this FakePoserLib3 would be related to what I want to do - run and debug code without Poser?
Characters, Body Sculpts, Morph Corrections, Outfits, Python Scripts, Universal Heads, and Videogames!
First and foremost the lib helps writing scripts. It allows the editor to correct and complete syntax (you write "poser." and the editor displays a list of parameters of "poser" to choose from - e.g. poser.Scene()). And so called "Type Hinting" is possible. The editor can protect you from comparing e.g. two variables which can't be compared with each other because they have different types.
Regarding debugging: All functions provided by Poser are built into Poser (as is the Python interpreter). Only this built-in interpreter can access these functions. Which means: You need Poser to successfully execute scripts made for Poser.
But what works: The lib builds "pods" for every Poser function. But they don't give a useful result when executed. Meaning: Some scripts are executed without errors. Only completely without a result. How far this helps debugging, you have to decide from case to case. I have built many wx-Python scripts where I redirected the "fill and work routines" when Poser was not actually available.
About the editor: I would recommend "PyCharm" in the first place. A really powerful Python editor, for whom hardly anything is impossible.In second place (but by far) perhaps VS code (dances at all weddings, can do a lot, but a lot only cumbersomely or with errors).
PyCharm: https://www.jetbrains.com/pycharm/
VS-Code: https://code.visualstudio.com/
Another thing to mention: Type hinting becomes more important with Python 3. Because Python 3 supports type hinting.
Thanks, man. I am not really looking for changing editors, especially not those with strings attached to subscriptions. I am happy with Sublime Text. I have paid for it, and it's mine forever. I just wanted to know how to use your script with Python3 in Poser 12. Sublime Text supports code hinting, but it is very limited, and obviously has no clue about the PoserPython API. Are you saying your library adds code hinting for the PoserPython API? That would be cool and really helpful. Is it possible to use it with Sublime Text?
Characters, Body Sculpts, Morph Corrections, Outfits, Python Scripts, Universal Heads, and Videogames!
If I just import the module as described above, would that alone provide code hinting?
Characters, Body Sculpts, Morph Corrections, Outfits, Python Scripts, Universal Heads, and Videogames!
Ken_1171 posted at 11:37AM Thu, 03 December 2020 - #4406268
Thanks, man. I am not really looking for changing editors, especially not those with strings attached to subscriptions.
PyCharm is the most complete Editor ever. The version for Python is free and complete, with all bells and wistles. No need to pay for it. I'm not so sure about VS-Code. Microsoft is looking for money everywhere :)
But: I'm not here to sell editors :) Use whatever you like.
Yes, if your editor supports code hinting for external libraries. I can't tell with Sublime, but with Visual Code and PyCharm hinting is available as soon as "import ...." was successfully typed (and the editor imported/analysed the lib).
Maybe you have to create the empty file "__ init__.py" in the directory where you stored the lib. This tells Python that it is allowed to load libs from this path.
adp001 posted at 2:07PM Thu, 03 December 2020 - #4406314
PyCharm is the most complete Editor ever. The version for Python is free and complete, with all bells and wistles. No need to pay for it.
I've got a copy of PyCharm from Humble Bundle that would expire in 1 year. After that, I would have to pay for the subscription if I wanted to keep using it, so I didn't even started. What if I liked it, but couldn't afford the subscription later? Now I wonder - if there is a free version with all the bells and whistles, why would people pay for the subscription? There must be a catch, right?
Characters, Body Sculpts, Morph Corrections, Outfits, Python Scripts, Universal Heads, and Videogames!
adp001 posted at 2:14PM Thu, 03 December 2020 - #4406316
Yes, if your editor supports code hinting for external libraries. I can't tell with Sublime, but with Visual Code and PyCharm hinting is available as soon as "import ...." was successfully typed (and the editor imported/analysed the lib).
Maybe you have to create the empty file "__ init__.py" in the directory where you stored the lib. This tells Python that it is allowed to load libs from this path.
Yes, Sublime Text supports both code completion and code hinting. However, I believe that "__ init__.py" file was deprecated in Python 3. We only need it in Python 2, which has already reached it's end-of-life cycle last year. Unless you are writing Python2 code, I believe we no longer need that file to identify module folders. Yay!
Thank you for taking the time to answer my questions. I will check out that code hinting link for Sublime Text. Does it do the same as your library?
Characters, Body Sculpts, Morph Corrections, Outfits, Python Scripts, Universal Heads, and Videogames!
Ken_1171 posted at 3:04PM Thu, 03 December 2020 - #4406337
adp001 posted at 2:07PM Thu, 03 December 2020 - #4406314
PyCharm is the most complete Editor ever. The version for Python is free and complete, with all bells and wistles. No need to pay for it.
I've got a copy of PyCharm from Humble Bundle that would expire in 1 year. After that, I would have to pay for the subscription if I wanted to keep using it, so I didn't even started. What if I liked it, but couldn't afford the subscription later? Now I wonder - if there is a free version with all the bells and whistles, why would people pay for the subscription? There must be a catch, right?
I provided a link where you can download it. Use the free version. The payed version is good if you want more then a Python IDE. That is what you have to pay for. The Python IDE is free and open source.
Here is the download page: https://www.jetbrains.com/pycharm/download/
Ken_1171 posted at 3:16PM Thu, 03 December 2020 - #4406339
Thank you for taking the time to answer my questions. I will check out that code hinting link for Sublime Text. Does it do the same as your library?
As far as I understand it, the plugin extends Sublime to have better support for hinting with external libs.
I'm not a Sublime user myself. I'm on Linux for all programming tasks. No need for paid editors on my side :)
Thanks for clarifying the paid vs free versions of PyCharm. I will give it a try. ^____^
Characters, Body Sculpts, Morph Corrections, Outfits, Python Scripts, Universal Heads, and Videogames!
Thank you for making this. As a visual studio/vscode user, flubbing around w/ poser's internal shell was driving me bonkers.
Have a decent flow now. Code creation on my wsl side w/ Netherworks' Scripts Auto Launch pane open and just hit "launch now" to test the script. /happy
-----sig-----
Daz, Blender, Affinity, Substance, Unity, Python, C#
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
http://adp.spdns.org
FakePoserLib3.zip
Includes a ready to go library for P11. Complete syntax from P11 should be covered now.
Use this at the top of your script:
and your Python-Editor will be able to do syntax-checking and hinting (tested with PyCharm + VSC). PyCharm also shows the help from the doc strings (not tested with VSC).