Tue, Nov 19, 7:19 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

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: Script to fix morph targets made using Hexagon 2.2


nruddock ( ) posted Sat, 14 July 2007 at 5:57 AM · edited Tue, 19 November 2024 at 7:19 AM

file_382817.doc

This script will reorder the vertices of an OBJ intended for use a morph target that has been exported from Hexagon 2.2

It is for single group morphs only.
To use for FBM work, you must be using a figure turned into a single group, and using UVmapper to save and replace the grouping.
Does not preserve normals, UV coordinates, or materials (which is why UVmapper is needed).

Can be run using either from the command line using a standalone python :-
python FixHexMT.py original.obj morph.obj fixed.obj

The script can be edited to supply the file paths.
All paths must be specified on the command line or in the script (i.e. the script supplied values do not act as defaults for missing command line arguments).

Can be run from Poser, in which case if all of the paths are not supplied by the script (i.e. one or more is blank) then FileChooser dialogs are used to collect the required filenames.

Discussions and bugs in this thread please.


dennisharoldsen ( ) posted Sat, 14 July 2007 at 11:04 PM

thank you


Pret-a-3D ( ) posted Sun, 15 July 2007 at 11:44 AM

I tried to run this on Mac OS, from terminal, python 2.3.5 and got this error: Traceback (most recent call last): File "/Users/pciccone/FixHexMT.py", line 42, in ? FILEIN1_FN = sys.arv[1] AttributeError: 'module' object has no attribute 'arv' I don 't know Python but all the other C-like languages I know use 'argv' instead of 'arv' so I tried to change it and it worked without errors except that when I try to load the MT in Morph Loader, for D|S, the plugin loads the file but says that there was no effect for the morph target. Any idea?

Paolo

https://www.preta3d.com
FB: https://www.facebook.com/RealityPlugIn
Tw: @preta3d
G+: https://plus.google.com/106625816153304163119
The Reality Gallery: https://reality-plug-in.deviantart.com


nruddock ( ) posted Sun, 15 July 2007 at 12:30 PM

file_382938.doc

> Quote - I tried to run this on Mac OS, from terminal, python 2.3.5 and got this error: Traceback (most recent call last): File "/Users/pciccone/FixHexMT.py", line 42, in ? FILEIN1_FN = sys.arv[1] AttributeError: 'module' object has no attribute 'arv' I don 't know Python but all the other C-like languages I know use 'argv' instead of 'arv' so I tried to change it and it worked without errors except that when I try to load the MT in Morph Loader, for D|S, the plugin loads the file but says that there was no effect for the morph target. Any idea?

Your right it's a typo.
Fixed script attached.


tentman ( ) posted Mon, 16 July 2007 at 12:55 AM

Thank you nruddock.

By the way, I got this error running on Poser6(J).

Traceback (most recent call last):
  File "", line 38, in ?
NameError: name 'False' is not define

To avoid this error, I added 2 lines to source codes.
(sorry, I'm not python programmer)

....(cut)....
import sys
import os.path

True=1   <----add
False=0  <----add

try:
    import poser
    isPoser = True
....(cut)....


nruddock ( ) posted Mon, 16 July 2007 at 2:57 AM

file_382996.doc

Sorry about that, a side effect of using Python 2.4


oscillator ( ) posted Mon, 16 July 2007 at 3:53 AM

Nice stuff! Thank you!

www.oscillator.se/3d - Shade tutorials and Poser freebies.


mylemonblue ( ) posted Sun, 22 July 2007 at 7:38 AM

Wow. Thanky! Everyone should be told about this.

Gotta get the puter up and running again....  *runs back to fixing puter *

My brain is just a toy box filled with weird things


fivecat ( ) posted Mon, 23 July 2007 at 7:34 PM

Thank you! Getting ready to play with Hex again, and this will come in handy.


nruddock ( ) posted Wed, 15 August 2007 at 4:23 PM

file_385458.doc

If your using a Mac, there appears to be a Python gremlin that causes no vertices to be written to the output file.

The attached script will hopefully cure that.
Operation on a PC should be unaffected, but to be on the safe side, if the script is working for you, then you don't need a new copy.


surreality ( ) posted Wed, 15 August 2007 at 4:36 PM

I may still be doing something screwy, but I'm still getting all 'f' lines and no 'v's that I can see in the output file version. I wish I could offer some sort of clue about the how and why, but I'm clueless there.

-D
---
It's all fun and games until someone loses an eye texture.


nruddock ( ) posted Wed, 15 August 2007 at 5:37 PM

file_385463.doc

I've made a small tweak and added a message to print out tsome values.

If it still doesn't work correctly, just post the output and I'll try figure out what's going on and how I can get some data from you to work on.


surreality ( ) posted Wed, 15 August 2007 at 6:11 PM · edited Wed, 15 August 2007 at 6:12 PM

Output: "Number of vertices read is 0" -- which makes me wonder if the Hex obj export for Mac is what is screwy. Quick edit: actually... maybe not. There are 'v' lines in the Hex exported obj.

-D
---
It's all fun and games until someone loses an eye texture.


nruddock ( ) posted Wed, 15 August 2007 at 6:49 PM

Quote - Output: "Number of vertices read is 0" -- which makes me wonder if the Hex obj export for Mac is what is screwy. Quick edit: actually... maybe not. There are 'v' lines in the Hex exported obj.

There should also be lines that start as follows printed out :-
File size ...
Number of lines ...

If your not seeing those then the fix isn't kicking in, so replace the following lines if (os.name == 'mac'):
lines = filein2.read()
lineSource = lines.split()
print "File size", len(lines)
print "Number of lines", len(lineSource)
else:
lineSource = filein2

with # if (os.name == 'mac'):
lines = filein2.read()
lineSource = lines.split()
print "File size", len(lines)
print "Number of lines", len(lineSource)
# else:
# lineSource = filein2

This should tell me at least something about what's happening.
I suspect that I'll need you to send me something exported from Hex (a cube would do), so that I can examine it.


surreality ( ) posted Wed, 15 August 2007 at 6:52 PM

Not a problem -- though I have to duck out for a few hours at the moment. As soon as I get back, I'll fire up hex and see what I can do.

-D
---
It's all fun and games until someone loses an eye texture.


surreality ( ) posted Wed, 15 August 2007 at 10:04 PM

Object uploaded and link in sitemail. grin I ended up getting the same message in terminal, however. I'm pretty sure I edited the script properly, but there's always the chance I didn't and can't tell, so you may want someone less code stupid than I am to double check also.

-D
---
It's all fun and games until someone loses an eye texture.


nruddock ( ) posted Thu, 16 August 2007 at 3:39 AM

file_385496.doc

Try this one. You should get 4 messages on the console, let me know what they are if it doesn't work.


broken-wings ( ) posted Thu, 23 August 2007 at 12:43 PM

for me it does´t work :(  Just beginning to hate my mac, running Tiger 10.4


nruddock ( ) posted Thu, 23 August 2007 at 1:39 PM

Quote - for me it does´t work :(  Just beginning to hate my mac, running Tiger 10.4

If your referring to the last script posted, then I'm pretty much out of ideas as to how to fix it for Macs.

Are you getting an error message, or is it still just not processing the vertices properly ?

As a last resort, if you have D|S, then you could use the version I did for that.


broken-wings ( ) posted Thu, 23 August 2007 at 6:59 PM

No real error-messages, the vertices are zero and poser tells me that there is a wrong number of vertices and nothing will happen, no import! I have used the script in poser 7 and not with terminal, perhaps i should try this! Think i will fire up my PC and work with Hexagon 2.1:unsure:


nruddock ( ) posted Fri, 24 August 2007 at 2:14 PM

Quote - Think i will fire up my PC and work with Hexagon 2.1:unsure:

If you have a PC, then you could install Python 2.4 and fix the files using that (the problem your experiencing only affects Macs).


NetFX ( ) posted Fri, 24 August 2007 at 6:22 PM

Man, i really need to thank you...this script works nice at WinVista with Poser 6 and Hex 2.2

It saved me lots of hair (my long hair wishes to thank you too :D )

Your great, nruddock...you really rocks!!!


broken-wings ( ) posted Sat, 25 August 2007 at 3:56 AM

Thank you, i will do this! And thank you, for trying to help  the mac-community...


nruddock ( ) posted Sat, 25 August 2007 at 5:20 AM

Quote - And thank you, for trying to help  the mac-community ...

If you continue run into problems, I'll consider doing a Java program.


broken-wings ( ) posted Sat, 25 August 2007 at 6:40 AM

That would be great! I think, many people will be glad about this, because DAZ don´t seems to fix this bug :crying: My PC is older than me :biggrin:


grichter ( ) posted Sat, 25 August 2007 at 7:47 AM

Total newbee to python...But I think the reference to os.name='mac' is for classic or Os9. for 10.+ or OSX I think it is 'posix'. I was messing around with some file path routines trying other peoples code and it didn't work until...A. printed the os,name and discovered it is 'posix'. B. edited the lines where required from 'mac' to 'posix' and it worked almost as expected. Granted total newwbee, so I could be 100 percent wrong. I no longer have a classic cpu to test this on as my newest machine is the intel chopped mac which can't run classic.

When I mean worked almost as expected...
Plus in early messing around, posix directory builds seem to me to like some variable + '/'+ filename vs what appears to be the wintel method of '' Again keep in mind I know about as much as you could put on the end of a pin head in regards to python.

If you use the '' method it appears it saves the file with a file name that is the entire file path runtimepsesomesubdirectorypose01.pz2 vs putting it where it is suppose to be with just the pose01.pz2 as the true and target file name.

Gary

"Those who lose themselves in a passion lose less than those who lose their passion"


nruddock ( ) posted Sat, 25 August 2007 at 1:05 PM

Quote - Total newbee to python...But I think the reference to os.name='mac' is for classic or Os9. for 10.+ or OSX I think it is 'posix'.

That would certainly explain part of the problem.
I know it's something I could sort out quickly if only I had access to a Mac.

I've been careful with the filename handling, there aren't, AFAICT, any OS specific operations in the original script.


grichter ( ) posted Sat, 25 August 2007 at 8:04 PM

If you have a section of code you want tested under OSX, I will gladly do it for you.

Gary

"Those who lose themselves in a passion lose less than those who lose their passion"


broken-wings ( ) posted Sat, 25 August 2007 at 8:28 PM

Me too! 😄


Lelu ( ) posted Mon, 03 September 2007 at 5:27 PM

Umm sorry can someone give me a brief explanation of how to use this? It just wants to open with my Word software.


broken-wings ( ) posted Mon, 03 September 2007 at 6:18 PM

Quote - Umm sorry can someone give me a brief explanation of how to use this? It just wants to open with my Word software.

You have to remove the ending .doc! The correct ending is .py


Lelu ( ) posted Tue, 04 September 2007 at 8:02 AM

Quote - > Quote - Umm sorry can someone give me a brief explanation of how to use this? It just wants to open with my Word software.

You have to remove the ending .doc! The correct ending is .py

 

Thankz I'll try that :D Then I just put it in my Poser python folder or what?


broken-wings ( ) posted Tue, 04 September 2007 at 12:14 PM

Quote - > Quote - > Quote - Umm sorry can someone give me a brief explanation of how to use this? It just wants to open with my Word software.

You have to remove the ending .doc! The correct ending is .py

 

Thankz I'll try that :D Then I just put it in my Poser python folder or what?

That´s the correct way! In Poser then you have to open the window "python-scripts" klick a empty button and then navigate to the script, so you can run it!


Lelu ( ) posted Wed, 05 September 2007 at 10:05 AM

Quote - > Quote - > Quote - > Quote - Umm sorry can someone give me a brief explanation of how to use this? It just wants to open with my Word software.

You have to remove the ending .doc! The correct ending is .py

 

Thankz I'll try that :D Then I just put it in my Poser python folder or what?

That´s the correct way! In Poser then you have to open the window "python-scripts" klick a empty button and then navigate to the script, so you can run it!

I must sound like a total idiot but I don't generally use Python scripts of any kind. I changed the file to a .py and loaded into Poser 5. When how do I use it? I tried to use it on a piece of clothing and I got an error message something about line 54? Then I can't select my python window, only to close it. Am I doing it all wrong?


nruddock ( ) posted Wed, 05 September 2007 at 12:50 PM

Quote - I must sound like a total idiot but I don't generally use Python scripts of any kind. I changed the file to a .py and loaded into Poser 5. When how do I use it? I tried to use it on a piece of clothing and I got an error message something about line 54? Then I can't select my python window, only to close it. Am I doing it all wrong?

Poser 5 doesn't have the DialogFileChooser method, so you'll need to edit the filenames into the script, or use it from the command line with a standalone Python install.


Lelu ( ) posted Wed, 05 September 2007 at 1:49 PM

Quote - > Quote - I must sound like a total idiot but I don't generally use Python scripts of any kind. I changed the file to a .py and loaded into Poser 5. When how do I use it? I tried to use it on a piece of clothing and I got an error message something about line 54? Then I can't select my python window, only to close it. Am I doing it all wrong?

Poser 5 doesn't have the DialogFileChooser method, so you'll need to edit the filenames into the script, or use it from the command line with a standalone Python install.

So it would work in Poser 6/7 but not in P5 then? How do I run it from the command line with a standalone Python install? Or for that matter edit the filenames into the script?


FrankT ( ) posted Sun, 30 September 2007 at 7:59 PM · edited Sun, 30 September 2007 at 7:59 PM

You need to rename the saved file so the extension is .py - delete the .doc extension basically (The forum software won't allow you to upload .py files directly)

My Freebies
Buy stuff on RedBubble


Lelu ( ) posted Mon, 01 October 2007 at 10:16 AM

Quote - You need to rename the saved file so the extension is .py - delete the .doc extension basically (The forum software won't allow you to upload .py files directly)

Thank you! I did get the correct .py file, and I have gotten it to work correctly in Poser since my last post. It seems for Poser 5 that you have to write the file names into the .py for each body part, anyway that's how it works for me. I really luv that it fixes this problem. Thankz again!


l3la ( ) posted Thu, 04 October 2007 at 4:50 PM

Thank you. I was hoping to use Hexagon to create morphs and now I can!


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.