Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 08 5:10 pm)
Explanation:
Function used_list() creates an array of the length of the vertices in the geometry, initialized with zeros. Then the polygons returned by Poser in UniMesh are scanned and the array is set to 1 where a polygon actually uses a vertex. Not used indices are later skipped (vertices not written).
Function crosslist() now uses this list instead of checking vertices for [0.0, 0.0, 0.0]. This caused problems if a polygon actually used [0.0, 0.0, 0.0].
As far as I can see, it seems like something is wrong with your file written from you modeller.
Can you import this file directly into Poser (with the "Import OBJ" function)?
For speed reasons the import function in the script does not check for problems or error conditions if only the file exists.
Script should run fine with P11 and P12. I didn't test P12, but an adapted form of the script in question (im_export.py) runs natively with Python 3.9.
Updated.
Now able to deal with more then one figure in the scene. Each figure will have a seperate entry in the config file for pathes and filenames.
If you want to join several morphs into one full body morph, do the following:
Don't move your figure from now on!
You may now delete all the morphs you have set to zero before.
Update
Supports Images, Bump and Transpareny for import into Blender better (mtl file).
Switch "Copy Imagefiles" on and off, because it makes no sense to copy the same images again and again to the same folder.
New version with some updates.
Most widgets are now "ownerdrawn". Should run with Poser 11 and 12. Don't know how it works with iOS.
If "Export Groups" is enabled, Blender, for example, can automatically make vertex groups out of them.
"Do not always leave "X Center == 0" switched on. It makes sense if, for example, the center vertices of a head were moved during morphing (they are at X position 0). This happens easily when working with the Soft-Brush. I often use the soft brush on one half of the head (or chest) and then let Poser calculate the other half of the face/chest with the morph tool. This solves the problem of not being able to work symetrically with posed figures in Blender (and other modelers).
Translated with www.DeepL.com/Translator (free version)
How to install:
The script consists of a main script ("Run.py") and a folder containing the required script parts to be loaded ("local_libs"). Create a separate folder for the script.Mine is called: "IM-EXporter". Unpack the ZIP file into this folder. From Poser you can then:
Path structure:
IM-EXporter
....local_libs
........__init__.py
........im_export.py
........wxPrepare.py
........WXTools.py
....Run.py
im_export.py contains anything to export a model and import a morph. The script strictly separates between UI part and the part that does the actual work. The result is that the import and export functions can be executed stand alone without any restrictions. And so of course can be used in your own script via "include".
wxPrePare.py contains functions that allows the script to work with both wxPython from Poser11 and Poser12 (i.e. Python 2 and Python 3).
WXTools.py contains wxPython functions and recreations of some standard controls ("ownerdrawn").
adp001 posted at 5:25AM Sat, 11 September 2021 - #4427160
How to install:
Thanks! I was going to ask about that, not having done anything with Poser Python for a decade. Also this looks like a nice demo on how to load local libs in scripts. If I don't get too distracted by other things, I'll give this a try tomorrow.
-- I'm not mad at you, just Westphalian.
Hey adp001, is it possible that you packaged an outdated Run.py
with the latest version? It's trying to read the IsChecked
property of a CheckboxCtrl
, which only has IsSelected
. Also it seems to register native checkbox callbacks that CheckboxCtril
does not have. I have less than zero knowledge of wx, though, so I may be completely misunderstanding something.
I managed to get the script to export a mesh with a morph on it, but none of the various option buttons seemed to do anything.
-- I'm not mad at you, just Westphalian.
odf posted at 8:42AM Sun, 12 September 2021 - #4427212
Ah, never mind, I wasn't seeing the complete interface. Looks like it's all working after my little tweaks.
ETA: Oh, "Import Morph" only seems to create a master channel with no dependencies. What am I doing wrong?
Shouldn't be empty. Only if there is nothing :)
The script checks for empty morphs and skips a morph if no deltas are created.
I tested it some minutes ago with a fresh figure. But to be sure I repacked anything so it reflects the newest changes also (added the current filenames in the tooltips for Ex-/Import; helps if "silent mode" is on). Just re-download please.
adp001 posted at 5:47PM Sun, 12 September 2021 - #4427226
odf posted at 8:53AM Sun, 12 September 2021 - #4427212
ETA: Oh, "Import Morph" only seems to create a master channel with no dependencies. What am I doing wrong?
If you import the same obj file you have exported, than the result is zero and no morphs are created :)
Maybe I'm not understanding the concept correctly. I apply some morphs to my figure, export, check in Blender that the morphs have been applied, set all morphs back to zero, import the OBJ that I've previously exported. That's not enough?
-- I'm not mad at you, just Westphalian.
Okay, turns out the only thing I really needed to change (on Poser 12.0.500) was the import wxPrepare
in WXTools.py to import local_libs.wxPrepare
. When loading the script I get an error complaining about a checkbox event with no object that I ignore, then the GUI for the tool appears and I only have to move it to a spot where I can see everything.
I have now managed to import a morph from an OBJ file using the tool. Do I understand correctly that I have to export the unmorphed figure each time directly before I import a new morph? Why is that necessary? I'm assuming some weirdness of the Poser interface?
-- I'm not mad at you, just Westphalian.
odf posted at 7:11PM Sun, 12 September 2021 - #4427269
Okay, turns out the only thing I really needed to change (on Poser 12.0.500) was the
import wxPrepare
in WXTools.py toimport local_libs.wxPrepare
.
Ups! Yes, Python 12 has different import logic. But I thought I catched that.... Thanks for finding that out! Will change it tomorrow.
When loading the script I get an error complaining about a checkbox event with no object that I ignore, then the GUI for the tool appears and I only have to move it to a spot where I can see everything.
Problem is that if an error is generated while wxPython is active, Poser Python often can't recover. Silly things may happen then :)
I have now managed to import a morph from an OBJ file using the tool. Do I understand correctly that I have to export the unmorphed figure each time directly before I import a new morph? Why is that necessary? I'm assuming some weirdness of the Poser interface?
No. One export at the start of a session. Pre-morphed or posed. Exports are the Reference used in the modeller. What you add or subtract to this reference is your imported morph. It's late here in germany and I'm pretty tired. I think I do something like a manual the next days (online and "realtime", but in German).
The gist of it (in technical terms) is:
morph = numpy.array(imported_vertices) - numpy.array(exported_vertices)
adp001 posted at 8:11PM Sun, 12 September 2021 - #4427273
odf posted at 7:11PM Sun, 12 September 2021 - #4427269
Okay, turns out the only thing I really needed to change (on Poser 12.0.500) was the
import wxPrepare
in WXTools.py toimport local_libs.wxPrepare
.Ups! Yes, Python 12 has different import logic. But I thought I catched that.... Thanks for finding that out! Will change it tomorrow.
When loading the script I get an error complaining about a checkbox event with no object that I ignore, then the GUI for the tool appears and I only have to move it to a spot where I can see everything.
Problem is that if an error is generated while wxPython is active, Poser Python often can't recover. Silly things may happen then :)
Just checking obj
for None before trying to access its name field got rid of that error.
I have now managed to import a morph from an OBJ file using the tool. Do I understand correctly that I have to export the unmorphed figure each time directly before I import a new morph? Why is that necessary? I'm assuming some weirdness of the Poser interface?
No. One export at the start of a session. Pre-morphed or posed. Exports are the Reference used in the modeller. What you add or subtract to this reference is your imported morph. It's late here in germany and I'm pretty tired. I think I do something like a manual the next days (online and "realtime", but in German).
The gist of it (in technical terms) is:
morph = numpy.array(imported_vertices) - numpy.array(exported_vertices)
Okay, that's making more sense to me now. It might be useful to make that more explicit in the interface. Maybe separate between reference and regular exports, display the file name of the reference export for the current figure, and if none exists either refuse to import morphs, issue a warning, or automatically create one.
-- I'm not mad at you, just Westphalian.
Fixed.
I guess I didn't get enough sleep the last few days and created a pretty creative error.
Everything worked for me as long as I didn't restart Poser. That rarely happens here, because Windows with active Poser runs in a virtual machine on a separate server and is rarely shut down. Except when I brought Poser to a halt using Python :) And that's exactly what happened, after which this script here suddenly stopped working for me too and I got a chance to find the error.
Thank you so much. Wonderful that you've written python that runs in both Poser 11 and 12. That's fantastic. For the time being I'm doing all my content creation from Poser 11 and most of the scripts that are being written new these days are all for Poser 12 but I don't use it for production, YET!
---Wolff On The Prowl---
Sorry for the late replay. I didn't get a notification.
I uploaded a version I'm using with P12 at the end of October:
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.
I am currently working on transferring Poser models to Blender with as little effort as possible. For this purpose I'm using parts of "PoMo" (FullbodyMorphs_wx4.py) from the beginning of the year, besides some other scripts. Again I stumbled over the problem with the unused vertices that Poser does not remove from the "UniMesh".
Old thread: https://www.renderosity.com/rr/mod/forumpro/?thread_id=2941172
Now I was forced to take care of the problem and came up with the following, really simple solution:
The returned list is then used in the following function, which creates a crosslist:
And the problem is solved. Quick and simple.
The new crosslist is used in the above mentioned script just like the previously created crosslist. But I don't save it anymore, I create it every time anew. The recalculation costs almost not noticeably more time.