Tue, Apr 23, 6:25 AM CDT

Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Mar 19 1:03 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Python editor support: New version


adp001 ( ) posted Sat, 18 April 2020 at 7:44 AM · edited Sun, 21 April 2024 at 10:01 PM

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:

try:
    import poser
except ImportError:
    import POSER_FAKE as poser

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).




an0malaus ( ) posted Sun, 19 April 2020 at 6:15 PM

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.



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


adp001 ( ) posted Mon, 20 April 2020 at 12:57 AM

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.




adp001 ( ) posted Tue, 21 April 2020 at 2:25 PM · edited Sun, 03 January 2021 at 9:54 AM

Here is the direct link to download:

http://adp.spdns.org/FakePoserLib3.zip




adp001 ( ) posted Sat, 21 November 2020 at 6:17 AM

Does anyone miss something when using this lib with P12?




adp001 ( ) posted Sat, 21 November 2020 at 6:47 AM

Found an incompatibility with P3 in the script to produce the lib.

Insert this at line 15:

if sys.version_info.major > 2:
    basestring = str
    xrange = range
else:
    range = xrange

Right before :

PARMS = namedtuple("PARMS", "Name args doc")

I'll update the zip on my website within the next 30 Minutes.




adp001 ( ) posted Sat, 21 November 2020 at 4:58 PM · edited Sun, 03 January 2021 at 9:55 AM

And here is the new version.

If you can, tell me if it works with P12. Thanks.

http://adp.spdns.org/FakePoserLib3a.zip




tsoren ( ) posted Mon, 30 November 2020 at 10:55 AM

That URL is currently returning a 404 error to me.

adp001 posted at 10:54AM Mon, 30 November 2020 - #4405426

And here is the new version.

If you can, tell me if it works with P12. Thanks.

http://adp.spdns.org/FakePoserLib3a.zip


adp001 ( ) posted Mon, 30 November 2020 at 1:33 PM

Fixed.




tsoren ( ) posted Tue, 01 December 2020 at 12:02 PM · edited Tue, 01 December 2020 at 12:02 PM

adp001 posted at 12:02PM Tue, 01 December 2020 - #4406056

Fixed.

Thank you


Ken1171_Designs ( ) posted Wed, 02 December 2020 at 4:21 PM

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?


adp001 ( ) posted Wed, 02 December 2020 at 6:56 PM · edited Wed, 02 December 2020 at 6:56 PM

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/




adp001 ( ) posted Wed, 02 December 2020 at 7:00 PM

Forgotten to mention: A good editor supported from the lib displays the "doc" string if you type a keyword or point with the mouse at one ("doc " string == description; actually what you will find in the manual about a Poser function).




adp001 ( ) posted Wed, 02 December 2020 at 7:04 PM · edited Sun, 03 January 2021 at 9:56 AM

Another thing to mention: Type hinting becomes more important with Python 3. Because Python 3 supports type hinting.

https://realpython.com/lessons/type-hinting/




Ken1171_Designs ( ) posted Wed, 02 December 2020 at 11:55 PM

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?


Ken1171_Designs ( ) posted Thu, 03 December 2020 at 12:02 AM

If I just import the module as described above, would that alone provide code hinting?


adp001 ( ) posted Thu, 03 December 2020 at 11:44 AM

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.




adp001 ( ) posted Thu, 03 December 2020 at 11:51 AM

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 Thu, 03 December 2020 at 12:05 PM · edited Sun, 03 January 2021 at 9:57 AM

Found something about Sublime Text that may help:

https://github.com/JulianEberius/SublimeRope




Ken1171_Designs ( ) posted Thu, 03 December 2020 at 2:13 PM

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?


Ken1171_Designs ( ) posted Thu, 03 December 2020 at 2:19 PM

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?


adp001 ( ) posted Thu, 03 December 2020 at 3:09 PM

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/




adp001 ( ) posted Thu, 03 December 2020 at 3:15 PM

There are more P11 Python users out there as P12 - for so mutch good reasons :) So it's clever to have a "init.py" if you want to publish your script ...




adp001 ( ) posted Thu, 03 December 2020 at 3:22 PM

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 :)




Ken1171_Designs ( ) posted Thu, 03 December 2020 at 3:54 PM

Thanks for clarifying the paid vs free versions of PyCharm. I will give it a try. ^____^


Vaskania ( ) posted Wed, 23 December 2020 at 9:14 PM · edited Wed, 23 December 2020 at 9:15 PM

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#


adp001 ( ) posted Fri, 25 December 2020 at 11:06 AM

Vaskania posted at 11:05AM Fri, 25 December 2020 - #4408349

Thank you for making this.

Thank you for saying this :)

You are the first...




heilei ( ) posted Thu, 31 March 2022 at 10:55 AM · edited Thu, 31 March 2022 at 10:58 AM

I know I'm rather late to the party, but just wanted to say THANK YOU to apd001 for making this! Just started fiddling with PyCharm & Poser again (after a longish hiatus), and this is a godsend when trying to learn the quirks of Poser's classes and methods. Good job!



structure ( ) posted Tue, 05 April 2022 at 2:11 AM · edited Tue, 05 April 2022 at 3:39 PM
Forum Coordinator

I no longer use sublime text ,I use VSCode for scripting.


Locked Out


Privacy Notice

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.